int main() { CTestSuite generalTestSuite; generalTestSuite.add(new TC_BasicFunctionality); generalTestSuite.add(new TC_ToggleCurrentLine()); generalTestSuite.add(new TC_GoBeforeTheFirstLine()); generalTestSuite.add(new TC_BasicDoublePrintCommand()); generalTestSuite.add(new TC_BasicDoublePrintWithNumberCommand()); generalTestSuite.add(new TC_MovingOnlyWithNumbers()); generalTestSuite.add(new TC_BasicRangePrinting()); generalTestSuite.add(new TC_InvalidRangePrinting()); generalTestSuite.run(); }
// // An own static function to collect the test functions into one // suite of tests. The framework will run the tests and free the // memory allocated for the test suite. // MTest* CTstNameValue::suiteL() { // Always use NewL (Do not use NewLC) !!! CTestSuite *suite = CTestSuite::NewL( _L8("CTstNameValue") ); suite->addTestL( CTestCaller< CTstNameValue >::NewL( _L8("TestConstructorL"), &TestConstructorL ) ); suite->addTestL( CTestCaller< CTstNameValue >::NewL( _L8("TestSettersGettersL"), &TestSettersGettersL ) ); return suite; }
// Exactly one exported function returning the suite of // test functions for the test runner in the framework. // (Always needed) // EXPORT_C MTest* CreateTestL () { CTestSuite *suite = CTestSuite::NewL(_L8("MceTimerManagerTest")); suite->addTestL(CMceTimerManagerTest::suiteL()); /* suite->addTestL(CMceCsReceiveQueueTest::suiteL()); suite->addTestL(CMceCsReceiverBaseTest::suiteL()); suite->addTestL(CMceCsSessionReceiverTest::suiteL()); suite->addTestL(CMceCsSubSessionReceiverTest::suiteL()); suite->addTestL(CMceCsSessionTest::suiteL()); suite->addTestL(CMceCsSubSessionTest::suiteL()); */ return suite; }
std::vector<std::string> CTestSuite::GetTestList(std::set<std::string>& SuitesToRun, bool bIncludeChildren) { std::vector<std::string> test_list; if(GetParentSuite()!=NULL && SuitesToRun.size()!=0) { std::string sSuiteName; std::string sSuiteDescription; GetSuiteInfo(sSuiteName, sSuiteDescription); // Check if this suite's name is in list std::set<std::string>::iterator it = SuitesToRun.find(sSuiteName); if(it==SuitesToRun.end()) return test_list; // This suite is not in list } test_list.push_back("SetUp"); DoWithMyTests(GET_NAMES, test_list); if(bIncludeChildren) { UINT i; for(i=0; i<GetChildSuiteCount(); i++) { CTestSuite* pChildSuite = GetChildSuite(i); std::vector<std::string> child_test_list = pChildSuite->GetTestList(SuitesToRun, bIncludeChildren); UINT j; for(j=0; j<child_test_list.size(); j++) { test_list.push_back(child_test_list[j]); } } } test_list.push_back("TearDown"); return test_list; }
std::vector<std::string> CTestSuite::GetErrorList(bool bIncludeChildren) { std::vector<std::string> asErrors = m_asErrorMsg; if(bIncludeChildren) { UINT i; for(i=0; i<GetChildSuiteCount(); i++) { CTestSuite* pChildSuite = GetChildSuite(i); std::vector<std::string> asChildErrors = pChildSuite->GetErrorList(bIncludeChildren); UINT j; for(j=0; j<asChildErrors.size(); j++) { asErrors.push_back(asChildErrors[j]); } } } return asErrors; }
int _tmain(int argc, TCHAR** argv) { if(argc==1) { _tprintf(_T("\nDo you want to run tests from a folder containing Chinese characters to test UNICODE compatibility (y/n)?\n")); _tprintf(_T("Your choice > ")); TCHAR szAnswer[1024]=_T(""); #if _MSC_VER>=1400 _getts_s(szAnswer, 1024); #else _getts(szAnswer); #endif if(_tcscmp(szAnswer, _T("y"))==0 || _tcscmp(szAnswer, _T("Y"))==0) { // Relaunch this process from another working directory containing UNICODE symbols in path. // This is needed to test all functionality on UNICODE compatibility. g_bRunningFromUNICODEFolder = TRUE; } if(g_bRunningFromUNICODEFolder) { _tprintf(_T("Launching tests in another process:\n")); if(g_bRunningFromUNICODEFolder) _tprintf(_T(" - with working directory having UNICODE symbols in path\n")); return fork(); } } else { int argnum; for(argnum=1; argnum<argc; argnum++) { TCHAR* szArg = argv[argnum]; if(_tcscmp(szArg, _T("/unicode"))==0) g_bRunningFromUNICODEFolder = TRUE; } } printf("\n=== Automated tests for CrashRpt v.%d.%d.%d ===\n\n", CRASHRPT_VER/1000, (CRASHRPT_VER%1000)/100, (CRASHRPT_VER%1000)%100); CTestRegistry* pRegistry = CTestRegistry::GetRegistry(); CTestSuite* pTopSuite = pRegistry->GetTopSuite(); // Print the list of test suites printf("The list of avaliable test suites:\n"); UINT nSuiteCount = pTopSuite->GetChildSuiteCount(); UINT i; for(i=0; i<nSuiteCount; i++) { CTestSuite* pSuite = pTopSuite->GetChildSuite(i); std::string sSuiteName; std::string sDescription; pSuite->GetSuiteInfo(sSuiteName, sDescription); printf(" - %s : %s\n", sSuiteName.c_str(), sDescription.c_str()); } printf("\nEnter which test suites to run (separate names by space) or enter empty line to run all test suites.\n"); printf("Your choice > "); char szSuiteList[1024]=""; #if _MSC_VER>=1400 gets_s(szSuiteList, 1024); #else gets(szSuiteList); #endif // Create the list of test suites to run std::string sSuiteList = szSuiteList; std::vector<std::string> aTokens = explode(sSuiteList); std::set<std::string> aTestSuitesToRun; for(i=0; i<aTokens.size(); i++) aTestSuitesToRun.insert(aTokens[i]); // Determine how many tests to run std::vector<std::string> test_list = pTopSuite->GetTestList(aTestSuitesToRun, true); size_t nTestsToRun = test_list.size(); printf("\nRunning tests...\n"); DWORD dwStartTicks = GetTickCount(); pTopSuite->Run(aTestSuitesToRun); DWORD dwFinishTicks = GetTickCount(); double dTimeElapsed = (dwFinishTicks-dwStartTicks)/1000.0; printf("\n=== Summary ===\n\n"); // Print all errors (if exist) std::vector<std::string> error_list = pTopSuite->GetErrorList(true); if(error_list.size()>0) { printf("Error list:\n"); for(i=0; i<error_list.size(); i++) { printf("%d: %s\n", i+1, error_list[i].c_str()); } } printf("\n Time elapsed: %0.2f sec.\n", dTimeElapsed); printf(" Test count: %d\n", nTestsToRun); size_t nErrorCount = error_list.size(); printf(" Tests passed: %d\n", nTestsToRun-nErrorCount); printf(" Tests failed: %d\n", nErrorCount); // Wait for key press _getch(); // Return non-zero value if there were errors return nErrorCount==0?0:1; }
MTest* CCamcTest_5::suiteL () { // Always use NewL (Do not use NewLC) !!! CTestSuite *suite = CTestSuite::NewL(_L8("CCamcTest_5")); CleanupStack::PushL( suite ); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.NUMBEROFMETADATAENTRIESL_001"), &NumberOfMetaDataEntriesL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.NUMBEROFMETADATAENTRIESL_002"), &NumberOfMetaDataEntriesL_002_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.METADATAENTRYL_001"), &MetaDataEntryL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.METADATAENTRYL_002"), &MetaDataEntryL_002_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.ADDMETADATAENTRYL_001"), &AddMetaDataEntryL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.ADDMETADATAENTRYL_002"), &AddMetaDataEntryL_002_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.REMOVEMETADATAENTRYL_001"), &RemoveMetaDataEntryL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.REMOVEMETADATAENTRYL_002"), &RemoveMetaDataEntryL_002_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.REPLACEMETADATAENTRYL_001"), &ReplaceMetaDataEntryL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.REPLACEMETADATAENTRYL_002"), &ReplaceMetaDataEntryL_002_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.SETPRIORITYL_005"), &SetPriorityL_005_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.GETPRIORITYL_001"), &GetPriorityL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.SETVIDEOFRAMERATEL_005"), &SetVideoFrameRateL_005_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.VIDEOFRAMERATEL_001"), &VideoFrameRateL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.SETVIDEOBITRATEL_005"), &SetVideoBitRateL_005_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.VIDEOBITRATEL_001"), &VideoBitRateL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.SETAUDIOBITRATEL_005"), &SetAudioBitRateL_005_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.AUDIOBITRATEL_001"), &AudioBitRateL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.SETAUDIOENABLEDL_005"), &SetAudioEnabledL_005_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.AUDIOENABLEDL_001"), &AudioEnabledL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.SETVIDEOFRAMESIZEL_006"), &SetVideoFrameSizeL_006_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.GETVIDEOFRAMESIZEL_001"), &GetVideoFrameSizeL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.PAUSEL_001"), &PauseL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.PAUSEL_002"), &PauseL_002_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.SETMAXCLIPSIZEL_005"), &SetMaxClipSizeL_005_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.SETGAINL_001"), &SetGainL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.SETGAINL_002"), &SetGainL_002_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.SETGAINL_003"), &SetGainL_003_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.GAINL_001"), &GainL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.MAXGAINL_001"), &MaxGainL_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.MAXGAINL_002"), &MaxGainL_002_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.STOP_001"), &Stop_001_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.STOP_002"), &Stop_002_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.STOP_003"), &Stop_003_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.STOP_004"), &Stop_004_L)); #ifdef __MPEG4_VIDEO_ENCODING suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.STOP_005"), &Stop_005_L)); #endif #ifndef __MPEG4_VIDEO_ENCODING suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.GETSUPPORTEDVIDEOTYPESL_001"), &GetSupportedVideoTypes_001_L)); #else suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.GETSUPPORTEDVIDEOTYPESL_002"), &GetSupportedVideoTypes_002_L)); #endif #if ((!defined __WINS__) || (!defined __WINSCW__)) // AAC supported only in HW // MP4 AAC + AMR suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.GETSUPPORTEDAUDIOTYPESL_003"), &GetSupportedAudioTypes_003_L)); suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.STOP_007"), &Stop_007_L)); #endif // AMR-only suite->addTestL(CTestCaller<CCamcTest_5>::NewL(_L8("CAMC_API.GETSUPPORTEDAUDIOTYPESL_001"), &GetSupportedAudioTypes_001_L)); CleanupStack::Pop( suite ); return suite; }
MTest* CCamcTest_visualcheck::suiteL () { // Always use NewL (Do not use NewLC) !!! CTestSuite *suite = CTestSuite::NewL(_L8("CCamcTest_visualcheck")); CleanupStack::PushL( suite ); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_101"), &VisualCheck_101_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_102"), &VisualCheck_102_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_103"), &VisualCheck_103_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_104"), &VisualCheck_104_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_105"), &VisualCheck_105_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_106"), &VisualCheck_106_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_107"), &VisualCheck_107_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_108_A"), &VisualCheck_108_A_L)); //Old Test VisualCheck_108 //suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_108_B"), &VisualCheck_108_B_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_109"), &VisualCheck_109_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_110"), &VisualCheck_110_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_111"), &VisualCheck_111_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_112"), &VisualCheck_112_L)); // Test 113 considered as obsolete. // suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_113"), &VisualCheck_113_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_114"), &VisualCheck_114_L)); #if !( defined (__WINS__) || defined (__WINSCW__) ) suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_115"), &VisualCheck_115_L)); #endif suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_116"), &VisualCheck_116_L)); suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_117"), &VisualCheck_117_L)); #ifdef __MPEG4_VIDEO_ENCODING suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_118"), &VisualCheck_118_L)); #endif #ifdef __MPEG4_VIDEO_ENCODING suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_119"), &VisualCheck_119_L)); #endif #ifdef __MPEG4_VIDEO_ENCODING suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_120"), &VisualCheck_120_L)); #endif #ifdef MP4_FILE_FORMAT_SUPPORTED suite->addTestL(CTestCaller<CCamcTest_visualcheck>::NewL(_L8("CAMC_API.VISUALCHECK_121"), &VisualCheck_121_L)); #endif CleanupStack::Pop( suite ); return suite; }
MTest* CCamcTest_1::suiteL () { // Always use NewL (Do not use NewLC) !!! CTestSuite *suite = CTestSuite::NewL(_L8("CCamcTest_1")); CleanupStack::PushL( suite ); suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_001"), &CCamcTest_1::OpenFileL_001_L)); suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_002"), &CCamcTest_1::OpenFileL_002_L)); // OPENFILEL_003 is not a valid test case. suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_004"), &CCamcTest_1::OpenFileL_004_L)); // OPENFILEL_005 is not relevent in current configuration. #ifdef __MPEG4_VIDEO_ENCODING suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_005"), &CCamcTest_1::OpenFileL_005_L)); #endif suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_006"), &CCamcTest_1::OpenFileL_006_L)); suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_008"), &CCamcTest_1::OpenFileL_008_L)); suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_009"), &CCamcTest_1::OpenFileL_009_L)); suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_010"), &CCamcTest_1::OpenFileL_010_L)); suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_011"), &CCamcTest_1::OpenFileL_011_L)); suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_017"), &CCamcTest_1::OpenFileL_017_L)); #ifdef __MPEG4_VIDEO_ENCODING suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_018"), &CCamcTest_1::OpenFileL_018_L)); #endif #ifdef MP4_FILE_FORMAT_SUPPORTED suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_020"), &CCamcTest_1::OpenFileL_020_L)); suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENFILEL_021"), &CCamcTest_1::OpenFileL_021_L)); #endif suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENDESCL_001"), &CCamcTest_1::OpenDesL_001_L)); suite->addTestL(CTestCaller<CCamcTest_1>::NewL(_L8("CAMC_API.OPENURLL_001"), &CCamcTest_1::OpenUrlL_001_L)); CleanupStack::Pop( suite ); return suite; }