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.

198 lines
4.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: tests.cpp
  7. //
  8. // Contents: Implementations of the Upper Layer unit tests
  9. //
  10. // Classes:
  11. //
  12. // Functions: StartTest1
  13. //
  14. // History: dd-mmm-yy Author Comment
  15. // 07-Feb-94 alexgo author
  16. //
  17. //--------------------------------------------------------------------------
  18. #include "pre.h"
  19. #include "iocs.h"
  20. #include "ias.h"
  21. #include "app.h"
  22. #include "site.h"
  23. #include "doc.h"
  24. #include <testmess.h>
  25. const CLSID CLSID_SimpleServer = {0xbcf6d4a0, 0xbe8c, 0x1068, { 0xb6, 0xd4,
  26. 0x00, 0xdd, 0x01, 0x0c, 0x05, 0x09 }};
  27. const CLSID CLSID_Paintbrush = {0x0003000a, 0, 0, { 0xc0, 0,0,0,0,0,0,0x46 }};
  28. //+-------------------------------------------------------------------------
  29. //
  30. // Function: StartTest1
  31. //
  32. // Synopsis: Starts unit test1, inserting a simple server object into
  33. // this (simpdnd) container.
  34. //
  35. // Effects:
  36. //
  37. // Arguments: pApp -- a pointer to the CSimpleApp that we're a part of
  38. //
  39. // Requires:
  40. //
  41. // Returns:
  42. //
  43. // Signals:
  44. //
  45. // Modifies:
  46. //
  47. // Algorithm:
  48. //
  49. // History: dd-mmm-yy Author Comment
  50. // 07-Feb-94 alexgo author
  51. //
  52. // Notes:
  53. //
  54. //--------------------------------------------------------------------------
  55. void StartTest1( CSimpleApp *pApp )
  56. {
  57. HRESULT hresult;
  58. static FORMATETC formatetc;
  59. //insert the simple server object
  60. formatetc.dwAspect = DVASPECT_CONTENT;
  61. formatetc.cfFormat = NULL;
  62. formatetc.lindex = -1;
  63. //need to create the client site
  64. pApp->m_lpDoc->m_lpSite = CSimpleSite::Create(pApp->m_lpDoc);
  65. hresult = OleCreate(CLSID_SimpleServer, IID_IOleObject,
  66. OLERENDER_DRAW, &formatetc,
  67. &pApp->m_lpDoc->m_lpSite->m_OleClientSite,
  68. pApp->m_lpDoc->m_lpSite->m_lpObjStorage,
  69. (void **)&(pApp->m_lpDoc->m_lpSite->m_lpOleObject));
  70. if( hresult != NOERROR )
  71. {
  72. goto errRtn;
  73. }
  74. //initialize the object
  75. hresult = pApp->m_lpDoc->m_lpSite->InitObject(TRUE);
  76. if( hresult == NOERROR )
  77. {
  78. //tell it to paint itself, then we'll quit
  79. PostMessage(pApp->m_lpDoc->m_hDocWnd, WM_PAINT, 0L, 0L);
  80. PostMessage(pApp->m_hDriverWnd, WM_TESTEND, TEST_SUCCESS,
  81. (LPARAM)hresult);
  82. PostMessage(pApp->m_hAppWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
  83. return;
  84. }
  85. errRtn:
  86. PostMessage(pApp->m_hDriverWnd, WM_TESTEND, TEST_FAILURE,
  87. (LPARAM)hresult);
  88. PostMessage(pApp->m_hAppWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
  89. return;
  90. }
  91. //+-------------------------------------------------------------------------
  92. //
  93. // Function: StartTest2
  94. //
  95. // Synopsis: Starts unit Test2, inserting a paintbrush object into
  96. // this (simpdnd) container.
  97. //
  98. // Effects:
  99. //
  100. // Arguments: pApp -- a pointer to the CSimpleApp that we're a part of
  101. //
  102. // Requires:
  103. //
  104. // Returns:
  105. //
  106. // Signals:
  107. //
  108. // Modifies:
  109. //
  110. // Algorithm:
  111. //
  112. // History: dd-mmm-yy Author Comment
  113. // 24-May-94 kevinro & alexgo author
  114. //
  115. // Notes:
  116. //
  117. //--------------------------------------------------------------------------
  118. void StartTest2( CSimpleApp *pApp )
  119. {
  120. HRESULT hresult;
  121. static FORMATETC formatetc;
  122. //insert the simple server object
  123. formatetc.dwAspect = DVASPECT_CONTENT;
  124. formatetc.cfFormat = NULL;
  125. formatetc.lindex = -1;
  126. //need to create the client site
  127. pApp->m_lpDoc->m_lpSite = CSimpleSite::Create(pApp->m_lpDoc);
  128. hresult = OleCreate(CLSID_Paintbrush, IID_IOleObject,
  129. OLERENDER_DRAW, &formatetc,
  130. &pApp->m_lpDoc->m_lpSite->m_OleClientSite,
  131. pApp->m_lpDoc->m_lpSite->m_lpObjStorage,
  132. (void **)&(pApp->m_lpDoc->m_lpSite->m_lpOleObject));
  133. if( hresult != NOERROR )
  134. {
  135. goto errRtn;
  136. }
  137. //initialize the object
  138. hresult = pApp->m_lpDoc->m_lpSite->InitObject(TRUE);
  139. //
  140. // The DDE layer is going to ignore all of the parameters except
  141. // the verb index. The parameters here are mostly dummies.
  142. //
  143. if (hresult == NOERROR)
  144. {
  145. hresult = pApp->m_lpDoc->m_lpSite->m_lpOleObject->DoVerb(0,
  146. NULL,
  147. &(pApp->m_lpDoc->m_lpSite->m_OleClientSite),
  148. -1,
  149. NULL,
  150. NULL);
  151. }
  152. if( hresult == NOERROR )
  153. {
  154. //tell it to paint itself, then we'll quit
  155. PostMessage(pApp->m_lpDoc->m_hDocWnd, WM_PAINT, 0L, 0L);
  156. PostMessage(pApp->m_hDriverWnd, WM_TESTEND, TEST_SUCCESS,
  157. (LPARAM)hresult);
  158. PostMessage(pApp->m_hAppWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
  159. return;
  160. }
  161. errRtn:
  162. PostMessage(pApp->m_hDriverWnd, WM_TESTEND, TEST_FAILURE,
  163. (LPARAM)hresult);
  164. PostMessage(pApp->m_hAppWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
  165. return;
  166. }