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.

138 lines
3.3 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File:
  4. // ctest.hxx
  5. //
  6. // Contents:
  7. // Primary include file for Cache Unit Test
  8. //
  9. // Classes:
  10. // TestInstance - Instance of cache unit test methods
  11. //
  12. // History:
  13. // 04-Sep-94 davepl Created
  14. //
  15. //-----------------------------------------------------------------------------
  16. //
  17. // PROTOTYPES
  18. //
  19. HRESULT EltIsInArray(STATDATA sdToFind, STATDATA rgStat[], DWORD cCount);
  20. ULONG __stdcall LaunchTestInstance(void *);
  21. int ConvHeightInPelsToLHM(HDC, int);
  22. int ConvWidthInPelsToLHM(HDC, int);
  23. int mprintf(LPCSTR szFormat, ...);
  24. int dprintf(LPCSTR szFormat, ...);
  25. //
  26. // Possible states for the unit test
  27. //
  28. typedef enum tagTEST_STATE
  29. {
  30. INVALID_STATE,
  31. TEST_STARTING,
  32. TESTING_ENUMERATOR,
  33. SAVE_AND_RELOAD,
  34. MULTI_CACHE,
  35. DATA_TEST,
  36. DRAW_METAFILE_NOW,
  37. DRAW_METAFILETILED_NOW,
  38. DRAW_DIB_NOW,
  39. DRAW_DIBTILED_NOW
  40. } TEST_STATE;
  41. //
  42. // Class which defines one particular Cache Test object
  43. //
  44. class TestInstance
  45. {
  46. private:
  47. IStorage *m_pStorage;
  48. IPersistStorage *m_pPersistStorage;
  49. IDataObject *m_pDataObject;
  50. IViewObject *m_pViewObject;
  51. OLECHAR m_wszStorage[ MAX_PATH ];
  52. TEST_STATE m_State;
  53. public:
  54. TestInstance();
  55. ~TestInstance();
  56. IOleCache *m_pOleCache;
  57. IOleCache2 *m_pOleCache2;
  58. HRESULT CreateAndInit(LPOLESTR lpwszStgName);
  59. HRESULT SaveCache();
  60. HRESULT LoadCache();
  61. HRESULT SaveAndReload();
  62. HRESULT AddMFCacheNode(DWORD *pdwCon);
  63. HRESULT AddEMFCacheNode(DWORD *pdwCon);
  64. HRESULT AddDIBCacheNode(DWORD *pdwCon);
  65. HRESULT AddBITMAPCacheNode(DWORD *pdwCon);
  66. HRESULT UncacheFormat(CLIPFORMAT);
  67. HRESULT EnumeratorTest();
  68. HRESULT MultiCache(DWORD dwCount);
  69. HRESULT CacheDataTest(char *, char *);
  70. HRESULT CompareDIB(HGLOBAL);
  71. HRESULT CompareMF(HGLOBAL);
  72. HRESULT DrawCacheToMetaFilePict(HGLOBAL *, BOOL);
  73. void Draw(HDC);
  74. TEST_STATE GetCurrentState();
  75. void SetCurrentState(TEST_STATE);
  76. };
  77. #ifndef DEF_LINDEX
  78. #define DEF_LINDEX (-1)
  79. #endif
  80. //
  81. // I N L I N E U T I L I T Y F U N C T I O N S
  82. //
  83. //+----------------------------------------------------------------------------
  84. //
  85. // Member: MassageErrorCode
  86. //
  87. // Synopsis: Takes a given HRESULT and converts it to S_OK if
  88. // [hrExpected] is the error code. If the HRESULT is
  89. // not S_OK and not Expected, it is left untouched.
  90. // If it was S_OK, it is changed to E_UNEXPECTED.
  91. //
  92. // Arguments: [hrExpected] The acceptable error code
  93. // [hrIn] The error code in question
  94. //
  95. // Returns: HRESULT (not as a success value for this fn)
  96. //
  97. // Notes:
  98. //
  99. // History: 23-Aug-94 Davepl Created
  100. //
  101. //-----------------------------------------------------------------------------
  102. inline HRESULT MassageErrorCode(HRESULT hrExpected, HRESULT hrIn)
  103. {
  104. if (hrExpected == hrIn)
  105. {
  106. return S_OK;
  107. }
  108. else if (S_OK == hrIn)
  109. {
  110. return E_UNEXPECTED;
  111. }
  112. else
  113. {
  114. return hrIn;
  115. }
  116. }