Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
2.7 KiB

  1. // Test.cpp: implementation of the CTest class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "TSDiag.h"
  6. #include "Test.h"
  7. //#include "tstst.h"
  8. #include "testdata.h"
  9. //////////////////////////////////////////////////////////////////////
  10. // Construction/Destruction
  11. //////////////////////////////////////////////////////////////////////
  12. CTest::CTest() : m_pTest(0), m_bTestRun(false)
  13. {
  14. }
  15. CTest::~CTest()
  16. {
  17. }
  18. STDMETHODIMP CTest::get_Name (BSTR *pVal)
  19. {
  20. if (!pVal)
  21. {
  22. return E_POINTER;
  23. }
  24. if (!IsValid())
  25. {
  26. return CO_E_NOTCONSTRUCTED;
  27. }
  28. CComBSTR bstr;
  29. bstr.LoadString(m_pTest->uiName);
  30. *pVal = bstr.Copy();
  31. return S_OK;
  32. }
  33. STDMETHODIMP CTest::get_Description (BSTR *pVal)
  34. {
  35. if (!pVal)
  36. {
  37. return E_POINTER;
  38. }
  39. if (!IsValid())
  40. {
  41. return CO_E_NOTCONSTRUCTED;
  42. }
  43. // bstr_t bstr = m_pTest->szTestName;
  44. // *pVal = bstr.copy();
  45. return E_NOTIMPL;
  46. }
  47. STDMETHODIMP CTest::get_IsApplicable (BOOL *pVal)
  48. {
  49. if (!pVal)
  50. {
  51. return E_POINTER;
  52. }
  53. if (!IsValid())
  54. {
  55. return CO_E_NOTCONSTRUCTED;
  56. }
  57. if (m_pTest->pfnNeedRunTest)
  58. {
  59. *pVal = (*m_pTest->pfnNeedRunTest)();
  60. }
  61. else
  62. {
  63. *pVal = true;
  64. }
  65. return S_OK;
  66. }
  67. STDMETHODIMP CTest::get_WhyNotApplicable (BSTR *pVal)
  68. {
  69. if (!pVal)
  70. {
  71. return E_POINTER;
  72. }
  73. if (!IsValid())
  74. {
  75. return CO_E_NOTCONSTRUCTED;
  76. }
  77. bstr_t bstr = m_pTest->TestDetails;
  78. *pVal = bstr.copy();
  79. return S_OK;
  80. }
  81. STDMETHODIMP CTest::Execute ()
  82. {
  83. if (!IsValid())
  84. {
  85. return CO_E_NOTCONSTRUCTED;
  86. }
  87. if (m_pTest->pfnNeedRunTest && !(*m_pTest->pfnNeedRunTest)())
  88. {
  89. return ERROR_INVALID_PARAMETER;
  90. }
  91. char szOutput[512];
  92. ostrstream oTestResult(szOutput, 512);
  93. ZeroMemory(oTestResult.str(), 512);
  94. m_eResult = (*m_pTest->pfnTestFunc)(oTestResult);
  95. m_bstrResult = oTestResult.str();
  96. m_bTestRun = true;
  97. return S_OK;
  98. }
  99. STDMETHODIMP CTest::get_Result (long *pVal)
  100. {
  101. if (!pVal)
  102. {
  103. return E_POINTER;
  104. }
  105. if (!IsValid())
  106. {
  107. return CO_E_NOTCONSTRUCTED;
  108. }
  109. if (!m_bTestRun)
  110. {
  111. return CO_E_NOTCONSTRUCTED;
  112. }
  113. *pVal = m_eResult;
  114. return S_OK;
  115. }
  116. STDMETHODIMP CTest::get_ResultString (BSTR *pVal)
  117. {
  118. if (!pVal)
  119. {
  120. return E_POINTER;
  121. }
  122. if (!IsValid())
  123. {
  124. return CO_E_NOTCONSTRUCTED;
  125. }
  126. if (!m_bTestRun)
  127. {
  128. return CO_E_NOTCONSTRUCTED;
  129. }
  130. *pVal = m_bstrResult.copy();
  131. return S_OK;
  132. }
  133. STDMETHODIMP CTest::get_ResultDetails (BSTR *pVal)
  134. {
  135. if (!pVal)
  136. {
  137. return E_POINTER;
  138. }
  139. if (!IsValid())
  140. {
  141. return CO_E_NOTCONSTRUCTED;
  142. }
  143. if (!m_bTestRun)
  144. {
  145. return CO_E_NOTCONSTRUCTED;
  146. }
  147. UINT uiDetailsResource = m_pTest->uiTestDetailsLocal;
  148. if (!IsItLocalMachine() && m_pTest->uiTestDetailsRemote != 0)
  149. {
  150. uiDetailsResource = m_pTest->uiTestDetailsRemote;
  151. }
  152. CComBSTR bstr;
  153. bstr.LoadString(uiDetailsResource);
  154. *pVal = bstr.Copy();
  155. return S_OK;
  156. }