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.

196 lines
4.5 KiB

  1. /*
  2. * csdrt.hxx
  3. */
  4. #include <ole2int.h>
  5. #include "objidl.h"
  6. #include "csguid.h"
  7. #include "comcat.h"
  8. #include "cstore.h"
  9. #define VerbosePrint if (fVerbose) printf
  10. typedef WCHAR Sname [_MAX_PATH];
  11. HRESULT RunTests();
  12. void CleanUp();
  13. void GetDefaultPlatform(CSPLATFORM *pPlatform);
  14. void GetUserClassStore(LPWSTR szPath);
  15. void CreateGuid(GUID *);
  16. void CreateUnique(WCHAR *, WCHAR *);
  17. void InitTempNames();
  18. HRESULT DoAdminEnumTests();
  19. HRESULT GetClassAdmin (LPOLESTR pszPath, IClassAdmin **pCA);
  20. HRESULT GetClassAccess ();
  21. HRESULT DoBrowseTest (IClassAdmin *pCA);
  22. HRESULT DoLogonPerfTest(BOOL fInitialize);
  23. HRESULT RefreshTest ();
  24. HRESULT DoAdminTest (ULONG *pcPkgCount);
  25. HRESULT DoRemoveTest (ULONG *pcPkgCount);
  26. HRESULT DoCoEnumAppsTest();
  27. HRESULT DoClassInfoTest();
  28. HRESULT EmptyClassStore (IClassAdmin *pCA);
  29. HRESULT DoCatTests(IClassAdmin *pIClassAdmin1, IClassAdmin *pIClassAdmin2);
  30. HRESULT EnumPackagesAndDelete(IClassAdmin *pCA,
  31. BOOL fDelete,
  32. ULONG *pcPackages);
  33. /*
  34. HRESULT EnumCategoriesAndDelete (IClassAdmin *pCA,
  35. BOOL fDelete,
  36. ULONG *pcClasses);
  37. void PrintCategoryDetail(CATEGORYINFO *pCatInfo);
  38. */
  39. void PrintInstallInfo(INSTALLINFO *pInstallInfo);
  40. void ReleasePackageDetail(PACKAGEDETAIL *pPackageDetail, BOOL fPartial);
  41. void PrintPackageInfo(PACKAGEDISPINFO *pPackageInfo);
  42. #define VerifyPackage(x,y) if (!(x)) { printf ("Package contents not as expected (%S...\n", y); return E_FAIL; }
  43. extern GUID NULLGUID;
  44. #define MACGetElemLOOP(E) \
  45. for(count=0;;) { \
  46. hr = E->Next(1, &obj, NULL); \
  47. if (FAILED(hr)) \
  48. { \
  49. printf("Error! Next in EnumTests returned 0x%x.\n", hr); \
  50. return hr; \
  51. } \
  52. \
  53. if (hr == S_FALSE) \
  54. { \
  55. VerbosePrint("Finished Enumerating\n"); \
  56. break; \
  57. } \
  58. count++;
  59. template<class ENUM, class TYPE>
  60. HRESULT EnumTests(ENUM *Enum, ULONG exp, ULONG *got, TYPE *elems, ULONG sz, BOOL Chk)
  61. {
  62. // BUGBUG:: Should have a compare routine also as part of the template.
  63. TYPE obj;
  64. ULONG count = 0;
  65. ENUM *Enum1=NULL;
  66. HRESULT hr = S_OK;
  67. if (got)
  68. (*got) = 0;
  69. MACGetElemLOOP(Enum)
  70. VerbosePrintObj(obj);
  71. if ((Chk) && (!ArrayCompare(elems, obj, sz)))
  72. VerbosePrint("Element does not match exactly\n");
  73. ReleaseObj(obj);
  74. }
  75. if (got) {
  76. (*got) = count;
  77. Enum->Release();
  78. return S_OK;
  79. }
  80. if (count != exp) {
  81. printf("Error! After Next: Expected number of elements %d, got %d\n", exp, count);
  82. return E_FAIL;
  83. }
  84. hr = Enum->Reset();
  85. if (FAILED(hr)) {
  86. printf("Error! Reset returned 0x%x\n", hr);
  87. return hr;
  88. }
  89. hr = Enum->Skip(1);
  90. if (FAILED(hr)) {
  91. printf("Error! Skip returned 0x%x\n", hr);
  92. return hr;
  93. }
  94. MACGetElemLOOP(Enum)
  95. ReleaseObj(obj);
  96. }
  97. if (count != (exp-1)) {
  98. printf("Error! After Skip: Expected number of elements %d, got %d\n", exp-1, count);
  99. return E_FAIL;
  100. }
  101. hr = Enum->Reset();
  102. if (FAILED(hr)) {
  103. printf("Error! Reset returned 0x%x\n", hr);
  104. return hr;
  105. }
  106. hr = Enum->Skip(1);
  107. if (FAILED(hr)) {
  108. printf("Error! Skip returned 0x%x\n", hr);
  109. return hr;
  110. }
  111. hr = Enum->Clone(&Enum1);
  112. if (FAILED(hr)) {
  113. printf("Error! Clone returned 0x%x\n", hr);
  114. return hr;
  115. }
  116. Enum->Release();
  117. MACGetElemLOOP(Enum1)
  118. ReleaseObj(obj);
  119. }
  120. if (count != (exp-1)) {
  121. printf("Error! After Skip: Expected number of elements %d, got %d\n", exp-1, count);
  122. return E_FAIL;
  123. }
  124. Enum1->Release();
  125. }
  126. BOOL Compare(WCHAR *sz1, WCHAR *sz2);
  127. BOOL Compare(CSPLATFORM cp1, CSPLATFORM cp2);
  128. BOOL Compare(GUID guid1, GUID guid2);
  129. BOOL Compare(DWORD dw1, DWORD dw2);
  130. BOOL Compare(CLASSDETAIL Cd1, CLASSDETAIL Cd2);
  131. BOOL Compare(ACTIVATIONINFO Av1, ACTIVATIONINFO Av2);
  132. BOOL Compare(INSTALLINFO If1, INSTALLINFO If2);
  133. BOOL Compare(PLATFORMINFO Pf1, PLATFORMINFO Pf2);
  134. BOOL Compare(PACKAGEDETAIL Pd1, PACKAGEDETAIL Pd2);
  135. BOOL Compare(PACKAGEDISPINFO Pi1, PACKAGEDISPINFO Pi2);
  136. BOOL Compare(CATEGORYINFO ci1, CATEGORYINFO ci2);
  137. template <class ArrayType>
  138. DWORD ArrayCompare(ArrayType *Array, ArrayType elem, DWORD len)
  139. {
  140. DWORD i;
  141. for (i = 0; i < len; i++)
  142. if (Compare(Array[i], elem))
  143. return i+1;
  144. return 0;
  145. }