Leaked source code of windows server 2003
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.

158 lines
3.5 KiB

  1. //+- -----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993.
  5. //
  6. // File: bm_activ.cxx
  7. //
  8. // Contents: Ole object activation test
  9. //
  10. // Classes: COleActivationTest
  11. //
  12. // History: 1-July-93 t-martig Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #include <headers.cxx>
  16. #pragma hdrstop
  17. #include <bm_activ.hxx>
  18. #include <oletest.hxx>
  19. TCHAR *COleActivationTest::Name ()
  20. {
  21. return TEXT("ObjActivation");
  22. }
  23. SCODE COleActivationTest::Setup (CTestInput *pInput)
  24. {
  25. SCODE sc;
  26. CTestBase::Setup(pInput);
  27. // get iteration count
  28. m_ulIterations = pInput->GetIterations(Name());
  29. // initialize state
  30. for (ULONG iCtx=0; iCtx<CNT_CLSCTX; iCtx++)
  31. {
  32. sc = pInput->GetGUID(&m_ClsID[iCtx], Name(), apszClsIDName[iCtx]);
  33. if (FAILED(sc))
  34. {
  35. Log (TEXT("Setup - GetClassID failed."), sc);
  36. return sc;
  37. }
  38. INIT_RESULTS(m_ulGetClassObjectTime[iCtx]);
  39. INIT_RESULTS(m_ulCreateInstanceTime[iCtx]);
  40. INIT_RESULTS(m_ulLoadTime[iCtx]);
  41. INIT_RESULTS(m_ulPunkReleaseTime[iCtx]);
  42. INIT_RESULTS(m_ulCFReleaseTime[iCtx]);
  43. }
  44. sc = InitCOM();
  45. if (FAILED(sc))
  46. {
  47. Log (TEXT("Setup - InitCOM failed."), sc);
  48. return sc;
  49. }
  50. return S_OK;
  51. }
  52. SCODE COleActivationTest::Cleanup ()
  53. {
  54. UninitCOM();
  55. return S_OK;
  56. }
  57. SCODE COleActivationTest::Run ()
  58. {
  59. CStopWatch sw;
  60. IPersistFile *pIPF = NULL;
  61. IClassFactory *pICF = NULL;
  62. for (ULONG iCtx=0; iCtx<CNT_CLSCTX; iCtx++)
  63. {
  64. for (ULONG iIter=0; iIter<m_ulIterations; iIter++)
  65. {
  66. sw.Reset ();
  67. SCODE sc = CoGetClassObject(m_ClsID[iCtx], dwaClsCtx[iCtx], NULL,
  68. IID_IClassFactory, (void **)&pICF);
  69. m_ulGetClassObjectTime[iCtx][iIter] = sw.Read ();
  70. Log (TEXT("CoGetClassObject"), sc);
  71. if (SUCCEEDED(sc))
  72. {
  73. sw.Reset();
  74. sc = pICF->CreateInstance(NULL, IID_IPersistFile, (void **)&pIPF);
  75. m_ulCreateInstanceTime[iCtx][iIter] = sw.Read ();
  76. Log (TEXT("CreateInstance"), sc);
  77. sw.Reset();
  78. pICF->Release();
  79. m_ulCFReleaseTime[iCtx][iIter] = sw.Read();
  80. if (SUCCEEDED(sc))
  81. {
  82. // load the data
  83. sw.Reset();
  84. pIPF->Load(apszPerstName[iCtx], 0);
  85. m_ulLoadTime[iCtx][iIter] = sw.Read();
  86. sw.Reset();
  87. pIPF->Release ();
  88. m_ulPunkReleaseTime[iCtx][iIter] = sw.Read();
  89. }
  90. else
  91. {
  92. m_ulCreateInstanceTime[iCtx][iIter] = NOTAVAIL;
  93. }
  94. }
  95. else
  96. {
  97. m_ulGetClassObjectTime[iCtx][iIter] = NOTAVAIL;
  98. }
  99. }
  100. }
  101. return S_OK;
  102. }
  103. SCODE COleActivationTest::Report (CTestOutput &output)
  104. {
  105. output.WriteSectionHeader (Name(), TEXT("CoGetClassObject"), *m_pInput);
  106. for (ULONG iCtx=0; iCtx<CNT_CLSCTX; iCtx++)
  107. {
  108. output.WriteString(TEXT("\n"));
  109. output.WriteClassID (&m_ClsID[iCtx]);
  110. output.WriteString(apszClsCtx[iCtx]);
  111. output.WriteString(TEXT("\n"));
  112. output.WriteResults (TEXT("CoGetClassObject"), m_ulIterations,
  113. m_ulGetClassObjectTime[iCtx]);
  114. output.WriteResults (TEXT("CreateInstance "), m_ulIterations,
  115. m_ulCreateInstanceTime[iCtx]);
  116. output.WriteResults (TEXT("pICF->Release "), m_ulIterations,
  117. m_ulCFReleaseTime[iCtx]);
  118. output.WriteResults (TEXT("pIPF->Load "), m_ulIterations,
  119. m_ulLoadTime[iCtx]);
  120. output.WriteResults (TEXT("pIPF->Release "), m_ulIterations,
  121. m_ulPunkReleaseTime[iCtx]);
  122. }
  123. return S_OK;
  124. }