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.

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