Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1320655
  • 博文数量: 179
  • 博客积分: 4141
  • 博客等级: 中将
  • 技术积分: 2083
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-21 20:04
文章存档

2024年(1)

2019年(13)

2016年(1)

2014年(16)

2011年(8)

2010年(25)

2009年(115)

分类: C/C++

2014-10-07 18:26:57

每一个测试项目,均需要一个Factory,充当运行的客户端或者服务端的入口

点击(此处)折叠或打开

  1. #pragma once

  2. namespace IMIX
  3. {
  4.     class IMIXApplication;
  5. }

  6. class CCaseIMIXFactory
  7. {
  8. public:
  9.     static CCaseIMIXFactory* GetInstance();

  10.     void RunTest(int type, IMIX::IMIXApplication *pApp, CApiOp *pApiOp);
  11. };

点击(此处)折叠或打开

  1. #include "UTILITY/Mutex.h"

  2. #include "IMIX/IMIXAPI/Listener.h"
  3. #include "IMIX/IMIXAPI/IMIXApplication.h"

  4. #include "Common.h"
  5. #include "ConfigGen.h"
  6. #include "TerminalConfig.h"

  7. #include "CommonListenerImpl.h"

  8. #include "TestObject.h"
  9. #include "ProtocolInc.h"
  10. #include "IMIXTestCaseObject.h"
  11. #include "ImixInc.h"

  12. using namespace IMIX;

  13. CCaseIMIXFactory* CCaseIMIXFactory::GetInstance()
  14. {
  15.     static CCaseIMIXFactory s_caseImixFactory;

  16.     return &s_caseImixFactory;
  17. }

  18. void CCaseIMIXFactory::RunTest(int type, IMIXApplication *pApp, CApiOp *pApiOp)
  19. {
  20.     int ty = type & TYPE_CASETYPE;

  21.     CIMIXTestCaseObject *ptestcase = NULL;

  22.     switch(ty)
  23.     {
  24.     case TYPE_APPINIT:
  25.         ptestcase = (CIMIXTestCaseObject*)CAppInit::GetInstance();
  26.         break;
  27.     case TYPE_HEARTBTINT:
  28.         ptestcase = (CIMIXTestCaseObject*)CHeartBtIntCase::GetInstance();
  29.         break;
  30.     case TYPE_IMIXTIMER:
  31.         ptestcase = (CIMIXTestCaseObject*)CIMIXTimerCase::GetInstance();
  32.         break;
  33.     case TYPE_RECONNECT:
  34.         ptestcase = (CIMIXTestCaseObject*)CReConnectCase::GetInstance();
  35.         break;
  36.     case TYPE_SESSIONCASE:
  37.         ptestcase = (CIMIXTestCaseObject*)CSessionCase::GetInstance();
  38.         break;
  39.     case TYPE_ERRORNO:
  40.         ptestcase = (CIMIXTestCaseObject *)CErrorNoCase::GetInstance();
  41.         break;
  42.     case TYPE_CSCASE:
  43.         ptestcase = (CIMIXTestCaseObject *)CCSCase::GetInstance();
  44.         break;
  45.     case TYPE_PERFORMANCECASE:
  46.         ptestcase = (CIMIXTestCaseObject *)CIMIXPerformanceCase::GetInstance();
  47.         break;
  48.     case TYPE_IMIXSEQCASE:
  49.         ptestcase = (CIMIXTestCaseObject *)CIMIXSeqCase::GetInstance();
  50.         break;
  51.     case TYPE_ATESTCASE:
  52.         ptestcase = (CIMIXTestCaseObject *)CATest::GetInstance();
  53.         break;
  54.     case TYPE_IMIXAPPLICATIONCASE:
  55.         ptestcase = (CIMIXTestCaseObject *)CIMIXApplicationCase::GetInstance();
  56.         break;
  57.     case TYPE_IMIXCONFIGFUNC:
  58.         ptestcase = (CIMIXTestCaseObject *)CIMIXConfigFunc::GetInstance();
  59.         break;
  60.     }

  61.     if (ptestcase != NULL)
  62.         ptestcase->RunTest(type, pApp, pApiOp);
  63. }

阅读(4453) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~