Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /******************************************************************** |
michael@0 | 2 | * COPYRIGHT: |
michael@0 | 3 | * Copyright (c) 2002-2005, International Business Machines Corporation and |
michael@0 | 4 | * others. All Rights Reserved. |
michael@0 | 5 | ********************************************************************/ |
michael@0 | 6 | |
michael@0 | 7 | /* Created by weiv 05/09/2002 */ |
michael@0 | 8 | |
michael@0 | 9 | /* Base class for data driven tests */ |
michael@0 | 10 | |
michael@0 | 11 | #ifndef U_TESTFW_TESTMODULE |
michael@0 | 12 | #define U_TESTFW_TESTMODULE |
michael@0 | 13 | |
michael@0 | 14 | #include "unicode/unistr.h" |
michael@0 | 15 | #include "unicode/ures.h" |
michael@0 | 16 | #include "unicode/testtype.h" |
michael@0 | 17 | #include "unicode/testdata.h" |
michael@0 | 18 | #include "unicode/datamap.h" |
michael@0 | 19 | #include "unicode/testlog.h" |
michael@0 | 20 | |
michael@0 | 21 | |
michael@0 | 22 | /* This class abstracts the actual organization of the |
michael@0 | 23 | * data for data driven tests |
michael@0 | 24 | */ |
michael@0 | 25 | |
michael@0 | 26 | |
michael@0 | 27 | class DataMap; |
michael@0 | 28 | class TestData; |
michael@0 | 29 | |
michael@0 | 30 | |
michael@0 | 31 | /** Main data driven test class. Corresponds to one named data |
michael@0 | 32 | * unit (such as a resource bundle. It is instantiated using |
michael@0 | 33 | * a factory method getTestDataModule |
michael@0 | 34 | */ |
michael@0 | 35 | class T_CTEST_EXPORT_API TestDataModule { |
michael@0 | 36 | const char* testName; |
michael@0 | 37 | |
michael@0 | 38 | protected: |
michael@0 | 39 | DataMap *fInfo; |
michael@0 | 40 | TestLog& fLog; |
michael@0 | 41 | |
michael@0 | 42 | public: |
michael@0 | 43 | /** Factory method. |
michael@0 | 44 | * @param name name of the test module. Usually name of a resource bundle or a XML file |
michael@0 | 45 | * @param log a logging class, used for internal error reporting. |
michael@0 | 46 | * @param status if something goes wrong, status will be set |
michael@0 | 47 | * @return a TestDataModule object. Use it to get test data from it |
michael@0 | 48 | */ |
michael@0 | 49 | static TestDataModule *getTestDataModule(const char* name, TestLog& log, UErrorCode &status); |
michael@0 | 50 | virtual ~TestDataModule(); |
michael@0 | 51 | |
michael@0 | 52 | protected: |
michael@0 | 53 | TestDataModule(const char* name, TestLog& log, UErrorCode& status); |
michael@0 | 54 | |
michael@0 | 55 | public: |
michael@0 | 56 | /** Name of this TestData module. |
michael@0 | 57 | * @return a name |
michael@0 | 58 | */ |
michael@0 | 59 | const char * getName() const; |
michael@0 | 60 | |
michael@0 | 61 | /** Get a pointer to an object owned DataMap that contains more information on this module |
michael@0 | 62 | * Usual fields are "Description", "LongDescription", "Settings". Also, if containing a |
michael@0 | 63 | * field "Headers" these will be used as the default headers, so that you don't have to |
michael@0 | 64 | * to specify per test headers. |
michael@0 | 65 | * @param info pass in a const DataMap pointer. If no info, it will be set to NULL |
michael@0 | 66 | */ |
michael@0 | 67 | virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const = 0; |
michael@0 | 68 | |
michael@0 | 69 | /** Create a test data object from an index. Helpful for integrating tests with current |
michael@0 | 70 | * intltest framework which addresses the tests by index. |
michael@0 | 71 | * @param index index of the test to be instantiated |
michael@0 | 72 | * @return an instantiated TestData object, ready to provide settings and cases for |
michael@0 | 73 | * the tests. |
michael@0 | 74 | */ |
michael@0 | 75 | virtual TestData* createTestData(int32_t index, UErrorCode &status) const = 0; |
michael@0 | 76 | |
michael@0 | 77 | /** Create a test data object from a name. |
michael@0 | 78 | * @param name name of the test to be instantiated |
michael@0 | 79 | * @return an instantiated TestData object, ready to provide settings and cases for |
michael@0 | 80 | * the tests. |
michael@0 | 81 | */ |
michael@0 | 82 | virtual TestData* createTestData(const char* name, UErrorCode &status) const = 0; |
michael@0 | 83 | }; |
michael@0 | 84 | |
michael@0 | 85 | class T_CTEST_EXPORT_API RBTestDataModule : public TestDataModule { |
michael@0 | 86 | public: |
michael@0 | 87 | virtual ~RBTestDataModule(); |
michael@0 | 88 | |
michael@0 | 89 | public: |
michael@0 | 90 | RBTestDataModule(const char* name, TestLog& log, UErrorCode& status); |
michael@0 | 91 | |
michael@0 | 92 | public: |
michael@0 | 93 | virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const; |
michael@0 | 94 | |
michael@0 | 95 | virtual TestData* createTestData(int32_t index, UErrorCode &status) const; |
michael@0 | 96 | virtual TestData* createTestData(const char* name, UErrorCode &status) const; |
michael@0 | 97 | |
michael@0 | 98 | private: |
michael@0 | 99 | UResourceBundle *getTestBundle(const char* bundleName, UErrorCode &status); |
michael@0 | 100 | |
michael@0 | 101 | private: |
michael@0 | 102 | UResourceBundle *fModuleBundle; |
michael@0 | 103 | UResourceBundle *fTestData; |
michael@0 | 104 | UResourceBundle *fInfoRB; |
michael@0 | 105 | UBool fDataTestValid; |
michael@0 | 106 | char *tdpath; |
michael@0 | 107 | |
michael@0 | 108 | /* const char* fTestName;*/ /* See name */ |
michael@0 | 109 | int32_t fNumberOfTests; |
michael@0 | 110 | |
michael@0 | 111 | }; |
michael@0 | 112 | |
michael@0 | 113 | |
michael@0 | 114 | #endif |
michael@0 | 115 |