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.

1352 lines
35 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: attest.cpp
  7. //
  8. // Contents: upper layer tests to test the apartment thread model
  9. //
  10. // Classes: CBareFactory
  11. // CATTestIPtrs
  12. //
  13. // Functions:
  14. // ATTest
  15. // CreateEHelperQuery
  16. // LinkObjectQuery
  17. // GetClipboardQuery
  18. // CreateEHTest
  19. // LinkObjectTest
  20. // GetClipboardTest
  21. // OleLinkMethods
  22. // OleObjectMethods
  23. // PersistStorageMethods
  24. // DataObjectMethods
  25. // RunnableObjectMethods
  26. // ViewObject2Methods
  27. // OleCache2Methods
  28. // ExternalConnectionsMethods
  29. // CHECK_FOR_THREAD_ERROR (macro)
  30. //
  31. // History: dd-mmm-yy Author Comment
  32. // 04-Jan-95 t-ScottH author
  33. //
  34. //--------------------------------------------------------------------------
  35. #include "oletest.h"
  36. #include "attest.h"
  37. #include "initguid.h"
  38. DEFINE_GUID(CLSID_SimpSvr,
  39. 0xBCF6D4A0,
  40. 0xBE8C,
  41. 0x1068,
  42. 0xB6,
  43. 0xD4,
  44. 0x00,
  45. 0xDD,
  46. 0x01,
  47. 0x0C,
  48. 0x05,
  49. 0x09);
  50. DEFINE_GUID(CLSID_StdOleLink,
  51. 0x00000300,
  52. 0,
  53. 0,
  54. 0xC0,
  55. 0,
  56. 0,
  57. 0,
  58. 0,
  59. 0,
  60. 0,
  61. 0x46);
  62. //+-------------------------------------------------------------------------
  63. //
  64. // Member: CATTestIPtrs::CATTestIPtrs(), public
  65. //
  66. // Synopsis: constructor
  67. //
  68. // Effects:
  69. //
  70. // Arguments: none
  71. //
  72. // Requires:
  73. //
  74. // Returns:
  75. //
  76. // Signals:
  77. //
  78. // Modifies:
  79. //
  80. // Derivation:
  81. //
  82. // Algorithm:
  83. //
  84. // History: dd-mmm-yy Author Comment
  85. // 12-Jan-95 t-ScottH author
  86. //
  87. // Notes:
  88. //
  89. //--------------------------------------------------------------------------
  90. CATTestIPtrs::CATTestIPtrs()
  91. {
  92. _pOleObject = NULL;
  93. _pOleCache2 = NULL;
  94. _pDataObject = NULL;
  95. _pPersistStorage = NULL;
  96. _pRunnableObject = NULL;
  97. _pViewObject2 = NULL;
  98. _pExternalConnection= NULL;
  99. _pOleLink = NULL;
  100. }
  101. //+-------------------------------------------------------------------------
  102. //
  103. // Member: CATTestIPtrs::Reset(), public
  104. //
  105. // Synopsis: resets all pointers to NULL
  106. //
  107. // Effects: releases all objects
  108. //
  109. // Arguments: none
  110. //
  111. // Requires:
  112. //
  113. // Returns: HRESULT
  114. //
  115. // Signals:
  116. //
  117. // Modifies: releases all objects and NULLs pointer
  118. //
  119. // Derivation:
  120. //
  121. // Algorithm:
  122. //
  123. // History: dd-mmm-yy Author Comment
  124. // 12-Jan-95 t-ScottH author
  125. //
  126. // Notes:
  127. //
  128. //--------------------------------------------------------------------------
  129. STDMETHODIMP CATTestIPtrs::Reset()
  130. {
  131. if (_pOleObject != NULL)
  132. {
  133. _pOleObject->Release();
  134. _pOleObject = NULL;
  135. }
  136. if (_pOleCache2 != NULL)
  137. {
  138. _pOleCache2->Release();
  139. _pOleCache2 = NULL;
  140. }
  141. if (_pDataObject != NULL)
  142. {
  143. _pDataObject->Release();
  144. _pDataObject = NULL;
  145. }
  146. if (_pPersistStorage != NULL)
  147. {
  148. _pPersistStorage->Release();
  149. _pPersistStorage = NULL;
  150. }
  151. if (_pRunnableObject != NULL)
  152. {
  153. _pRunnableObject->Release();
  154. _pRunnableObject = NULL;
  155. }
  156. if (_pViewObject2 != NULL)
  157. {
  158. _pViewObject2->Release();
  159. _pViewObject2 = NULL;
  160. }
  161. if (_pExternalConnection != NULL)
  162. {
  163. _pExternalConnection->Release();
  164. _pExternalConnection = NULL;
  165. }
  166. if (_pOleLink != NULL)
  167. {
  168. _pOleLink->Release();
  169. _pOleLink = NULL;
  170. }
  171. return NOERROR;
  172. }
  173. //+-------------------------------------------------------------------------
  174. //
  175. // Member: CBareFactory::CBareFactory, public
  176. //
  177. // Synopsis: constructor for the class factory
  178. //
  179. // Effects:
  180. //
  181. // Arguments: none
  182. //
  183. // Returns: void
  184. //
  185. // Modifies: initializes _cRefs
  186. //
  187. // Derivation: IClassFactory
  188. //
  189. // History: dd-mmm-yy Author Comment
  190. // 11-Jan-95 t-ScottH author
  191. //
  192. // Notes:
  193. //
  194. //--------------------------------------------------------------------------
  195. CBareFactory::CBareFactory()
  196. {
  197. _cRefs = 1;
  198. }
  199. //+-------------------------------------------------------------------------
  200. //
  201. // Member: CBareFactory::QueryInterface, public
  202. //
  203. // Synopsis: only IUnknown and IClassFactory are supported
  204. //
  205. // Effects:
  206. //
  207. // Arguments: [iid] -- the requested interface
  208. // [ppvObj]-- where to put the interface pointer
  209. //
  210. // Returns: HRESULT
  211. //
  212. // Modifies: ppvObj
  213. //
  214. // Derivation: IClassFactory
  215. //
  216. // History: dd-mmm-yy Author Comment
  217. // 11-Jan-95 t-ScottH author
  218. //
  219. // Notes:
  220. //
  221. //--------------------------------------------------------------------------
  222. STDMETHODIMP CBareFactory::QueryInterface (REFIID iid, LPVOID FAR* ppvObj)
  223. {
  224. if( IsEqualIID(iid, IID_IClassFactory) ||
  225. IsEqualIID(iid, IID_IUnknown) )
  226. {
  227. *ppvObj = this;
  228. AddRef();
  229. return NOERROR;
  230. }
  231. else
  232. {
  233. *ppvObj = NULL;
  234. return E_NOINTERFACE;
  235. }
  236. }
  237. //+-------------------------------------------------------------------------
  238. //
  239. // Member: CBareFactory::AddRef, public
  240. //
  241. // Synopsis: increments the reference count
  242. //
  243. // Effects:
  244. //
  245. // Arguments: none
  246. //
  247. // Returns: ULONG -- the new reference count
  248. //
  249. // Modifies:
  250. //
  251. // Derivation: IClassFactory
  252. //
  253. // History: dd-mmm-yy Author Comment
  254. // 11-Jan-95 t-ScottH author
  255. //
  256. // Notes:
  257. //
  258. //--------------------------------------------------------------------------
  259. STDMETHODIMP_(ULONG) CBareFactory::AddRef (void)
  260. {
  261. _cRefs++;
  262. return _cRefs;
  263. }
  264. //+-------------------------------------------------------------------------
  265. //
  266. // Member: CBareFactory::Release, public
  267. //
  268. // Synopsis: decrements the reference count
  269. //
  270. // Effects: deletes object when reference count is zero
  271. //
  272. // Arguments: none
  273. //
  274. // Returns: ULONG -- the new reference count
  275. //
  276. // Modifies:
  277. //
  278. // Derivation: IClassFactory
  279. //
  280. // History: dd-mmm-yy Author Comment
  281. // 11-Jan-95 t-ScottH author
  282. //
  283. // Notes:
  284. //
  285. //--------------------------------------------------------------------------
  286. STDMETHODIMP_(ULONG) CBareFactory::Release (void)
  287. {
  288. _cRefs--;
  289. if( _cRefs == 0 )
  290. {
  291. delete this;
  292. return 0;
  293. }
  294. return _cRefs;
  295. }
  296. //+-------------------------------------------------------------------------
  297. //
  298. // Member: CBareFactory::CreateInstance, public
  299. //
  300. // Synopsis: does nothing
  301. //
  302. // Effects:
  303. //
  304. // Arguments: [pUnkOuter] -- the controlling unknown for aggregation
  305. // [iid] -- the requested interface
  306. // [ppvObj] -- where to put the interface pointer
  307. //
  308. // Returns: HRESULT
  309. //
  310. // Modifies:
  311. //
  312. // Derivation: IClassFactory
  313. //
  314. // History: dd-mmm-yy Author Comment
  315. // 11-Jan-95 t-ScottH author
  316. //
  317. // Notes:
  318. //
  319. //--------------------------------------------------------------------------
  320. STDMETHODIMP CBareFactory::CreateInstance (
  321. LPUNKNOWN pUnkOuter,
  322. REFIID iid,
  323. LPVOID FAR* ppv)
  324. {
  325. return E_NOTIMPL;;
  326. }
  327. //+-------------------------------------------------------------------------
  328. //
  329. // Member: CBareFactory::LockServer, public
  330. //
  331. // Synopsis: does nothing
  332. //
  333. // Effects:
  334. //
  335. // Arguments: [flock] -- specifies the lock count
  336. //
  337. // Returns: HRESULT
  338. //
  339. // Modifies:
  340. //
  341. // History: dd-mmm-yy Author Comment
  342. // 11-Jan-95 t-ScottH author
  343. //
  344. // Notes:
  345. //
  346. //--------------------------------------------------------------------------
  347. STDMETHODIMP CBareFactory::LockServer ( BOOL fLock )
  348. {
  349. return NOERROR;
  350. }
  351. //+-------------------------------------------------------------------------
  352. //
  353. // Function: CHECK_FOR_THREAD_ERROR (macro)
  354. //
  355. // Synopsis: make sure that the hresult is RPC_E_WRONG_THREAD
  356. //
  357. // Effects: exits thread if hresult != RPC_E_WRONG
  358. //
  359. // Arguments: [hresult] -- error code
  360. //
  361. // Requires:
  362. //
  363. // Returns:
  364. //
  365. // Signals:
  366. //
  367. // Modifies:
  368. //
  369. // Algorithm:
  370. //
  371. // History: dd-mmm-yy Author Comment
  372. // 09-Jan-95 t-ScottH author
  373. //
  374. // Notes:
  375. //
  376. //--------------------------------------------------------------------------
  377. #define CHECK_FOR_THREAD_ERROR(hresult) \
  378. if (hresult != RPC_E_WRONG_THREAD) \
  379. { \
  380. OutputString("Expected RPC_E_WRONG_THREAD but received %x.\r\n", hresult); \
  381. assert(hresult == RPC_E_WRONG_THREAD); \
  382. ExitThread((DWORD)E_UNEXPECTED); \
  383. }
  384. // globals
  385. CATTestIPtrs g_IPtrs;
  386. //+-------------------------------------------------------------------------
  387. //
  388. // Function: ATTest
  389. //
  390. // Synopsis: calls the query functions to get pointers to the
  391. // supported interfaces
  392. //
  393. // Effects:
  394. //
  395. // Arguments: void
  396. //
  397. // Requires:
  398. //
  399. // Returns: void
  400. //
  401. // Signals:
  402. //
  403. // Modifies: globals g_IPtrs._pOleObject
  404. // g_IPtrs._pPersistStorage
  405. // g_IPtrs._pDataObject
  406. // g_IPtrs._pRunnableObject
  407. // g_IPtrs._pViewObject2
  408. // g_IPtrs._pOleCache2
  409. // g_IPtrs._pExternalConnection
  410. // g_IPtrs._pOleLink
  411. //
  412. // Algorithm:
  413. //
  414. // History: dd-mmm-yy Author Comment
  415. // 06-Jan-95 t-ScottH author
  416. //
  417. // Notes:
  418. //
  419. //--------------------------------------------------------------------------
  420. void ATTest(void)
  421. {
  422. HRESULT hresult;
  423. hresult = OleInitialize(NULL);
  424. assert(hresult == S_OK);
  425. // the functions CreateEHelperQuery, LinkObjectQuery and
  426. // GetClipboardQuery return either NOERROR or E_UNEXPECTED.
  427. // NOERROR is defined as 0
  428. hresult = CreateEHelperQuery();
  429. g_IPtrs.Reset();
  430. hresult |= LinkObjectQuery();
  431. g_IPtrs.Reset();
  432. hresult |= GetClipboardQuery();
  433. vApp.Reset();
  434. vApp.m_wparam = (hresult == NOERROR) ? TEST_SUCCESS : TEST_FAILURE;
  435. vApp.m_lparam = (LPARAM)hresult;
  436. vApp.m_message = WM_TESTEND;
  437. HandleTestEnd();
  438. OleUninitialize();
  439. return;
  440. }
  441. //+-------------------------------------------------------------------------
  442. //
  443. // Function: GetClipboardQuery
  444. //
  445. // Synopsis: get a pointer to IDataObject interface, create a new thread
  446. // to test proper exit/error codes, wait for the thread to
  447. // complete and return the thread's exit code
  448. //
  449. // Effects: creates new thread
  450. //
  451. // Arguments: none
  452. //
  453. // Requires:
  454. //
  455. // Returns: HRESULT
  456. //
  457. // Signals:
  458. //
  459. // Modifies: g_IPtrs._pDataObject
  460. //
  461. // Algorithm:
  462. //
  463. // History: dd-mmm-yy Author Comment
  464. // 11-Jan-95 t-ScottH author
  465. //
  466. // Notes:
  467. //
  468. //--------------------------------------------------------------------------
  469. HRESULT GetClipboardQuery(void)
  470. {
  471. HRESULT hresult;
  472. HANDLE hTestInterfaceThread;
  473. DWORD dwThreadId = 0;
  474. DWORD dwThreadExitCode;
  475. hresult = OleGetClipboard( &g_IPtrs._pDataObject );
  476. assert(hresult == S_OK );
  477. hTestInterfaceThread = CreateThread(
  478. NULL, // security attributes
  479. 0, // stack size (default)
  480. (LPTHREAD_START_ROUTINE)&GetClipboardTest, // address of thread function
  481. NULL, // arguments of thread function
  482. 0, // creation flags
  483. &dwThreadId ); // address of new thread ID
  484. assert(hTestInterfaceThread != NULL); //ensure that we have a valid thread handle
  485. // wait for the thread object so we can examine the error code
  486. WaitForSingleObject(hTestInterfaceThread, INFINITE);
  487. GetExitCodeThread(hTestInterfaceThread, &dwThreadExitCode);
  488. hresult = (HRESULT)dwThreadExitCode;
  489. CloseHandle(hTestInterfaceThread);
  490. return hresult;
  491. }
  492. //+-------------------------------------------------------------------------
  493. //
  494. // Function: LinkObjectQuery
  495. //
  496. // Synopsis: get a pointer to available interfaces, create a new thread
  497. // to test proper exit/error codes, wait for the thread to
  498. // complete and return the thread's exit code
  499. //
  500. // Effects:
  501. //
  502. // Arguments: none
  503. //
  504. // Requires:
  505. //
  506. // Returns: HRESULT
  507. //
  508. // Signals:
  509. //
  510. // Modifies: g_IPtrs._pOleObject
  511. // g_IPtrs._pPersistStorage
  512. // g_IPtrs._pDataObject
  513. // g_IPtrs._pRunnableObject
  514. // g_IPtrs._pViewObject2
  515. // g_IPtrs._pOleCache2
  516. // g_IPtrs._pOleLink
  517. //
  518. // Algorithm:
  519. //
  520. // History: dd-mmm-yy Author Comment
  521. // 11-Jan-95 t-ScottH author
  522. //
  523. // Notes:
  524. //
  525. //--------------------------------------------------------------------------
  526. HRESULT LinkObjectQuery(void)
  527. {
  528. HRESULT hresult;
  529. HANDLE hTestInterfaceThread;
  530. DWORD dwThreadId = 0;
  531. DWORD dwThreadExitCode;
  532. hresult = CoCreateInstance(
  533. CLSID_StdOleLink, // class ID of the object class
  534. NULL, // controlling unknown fro aggregation
  535. CLSCTX_INPROC, // context to run executables
  536. IID_IOleObject, // the requested interface
  537. (void **)&g_IPtrs._pOleObject); // where to store pointer to interface
  538. assert(hresult == S_OK);
  539. hresult = g_IPtrs._pOleObject->QueryInterface(IID_IPersistStorage, (void **)&g_IPtrs._pPersistStorage);
  540. assert(hresult == S_OK);
  541. hresult = g_IPtrs._pOleObject->QueryInterface(IID_IDataObject, (void **)&g_IPtrs._pDataObject);
  542. assert(hresult == S_OK);
  543. hresult = g_IPtrs._pOleObject->QueryInterface(IID_IRunnableObject, (void **)&g_IPtrs._pRunnableObject);
  544. assert(hresult == S_OK);
  545. hresult = g_IPtrs._pOleObject->QueryInterface(IID_IViewObject2, (void **)&g_IPtrs._pViewObject2);
  546. assert(hresult == S_OK);
  547. hresult = g_IPtrs._pOleObject->QueryInterface(IID_IOleCache2, (void **)&g_IPtrs._pOleCache2);
  548. assert(hresult == S_OK);
  549. hresult = g_IPtrs._pOleObject->QueryInterface(IID_IOleLink, (void **)&g_IPtrs._pOleLink);
  550. assert(hresult == S_OK);
  551. hTestInterfaceThread = CreateThread(
  552. NULL, // security attributes
  553. 0, // stack size (default)
  554. (LPTHREAD_START_ROUTINE)&LinkObjectTest,// address of thread function
  555. NULL, // arguments of thread function
  556. 0, // creation flags
  557. &dwThreadId ); // address of new thread ID
  558. assert(hTestInterfaceThread != NULL); //ensure that we have a valid thread handle
  559. // wait for the thread object so we can examine the error code
  560. WaitForSingleObject(hTestInterfaceThread, INFINITE);
  561. GetExitCodeThread(hTestInterfaceThread, &dwThreadExitCode);
  562. hresult = (HRESULT)dwThreadExitCode;
  563. CloseHandle(hTestInterfaceThread);
  564. return hresult;
  565. }
  566. //+-------------------------------------------------------------------------
  567. //
  568. // Function: CreateEHelperQuery
  569. //
  570. // Synopsis: get a pointer to available interfaces, create a new thread
  571. // to test proper exit/error codes, wait for the thread to
  572. // complete and return the thread's exit code
  573. //
  574. // Effects:
  575. //
  576. // Arguments: none
  577. //
  578. // Requires:
  579. //
  580. // Returns: HRESULT
  581. //
  582. // Signals:
  583. //
  584. // Modifies: g_IPtrs._pOleObject
  585. // g_IPtrs._pPersistStorage
  586. // g_IPtrs._pDataObject
  587. // g_IPtrs._pRunnableObject
  588. // g_IPtrs._pViewObject2
  589. // g_IPtrs._pOleCache2
  590. // g_IPtrs._pExternalConnection
  591. //
  592. // Algorithm:
  593. //
  594. // History: dd-mmm-yy Author Comment
  595. // 11-Jan-95 t-ScottH author
  596. //
  597. // Notes:
  598. //
  599. //--------------------------------------------------------------------------
  600. HRESULT CreateEHelperQuery(void)
  601. {
  602. HRESULT hresult;
  603. HANDLE hTestInterfaceThread;
  604. DWORD dwThreadId = 0;
  605. DWORD dwThreadExitCode;
  606. CBareFactory *pCF = new CBareFactory;
  607. // must use EMBDHLP_DELAYCREATE flag otherwise API will try pCF->CreateInstance
  608. // and verify pointer. CBareFactory::CreateInstance is not implemented!
  609. hresult = OleCreateEmbeddingHelper(
  610. CLSID_SimpSvr, // class ID of the server
  611. NULL, // controlling unknown for aggregation
  612. EMBDHLP_INPROC_SERVER | EMBDHLP_DELAYCREATE,// flags
  613. pCF, // pointer to server's class factory
  614. IID_IOleObject, // the requested interface
  615. (void **)&g_IPtrs._pOleObject ); // where to store pointer to interface
  616. assert(hresult == S_OK);
  617. hresult = g_IPtrs._pOleObject->QueryInterface(IID_IPersistStorage, (void **)&g_IPtrs._pPersistStorage);
  618. assert(hresult == S_OK);
  619. hresult = g_IPtrs._pOleObject->QueryInterface(IID_IDataObject, (void **)&g_IPtrs._pDataObject);
  620. assert(hresult == S_OK);
  621. hresult = g_IPtrs._pOleObject->QueryInterface(IID_IRunnableObject, (void **)&g_IPtrs._pRunnableObject);
  622. assert(hresult == S_OK);
  623. hresult = g_IPtrs._pOleObject->QueryInterface(IID_IViewObject2, (void **)&g_IPtrs._pViewObject2);
  624. assert(hresult == S_OK);
  625. hresult = g_IPtrs._pOleObject->QueryInterface(IID_IOleCache2, (void **)&g_IPtrs._pOleCache2);
  626. assert(hresult == S_OK);
  627. hresult = g_IPtrs._pOleObject->QueryInterface(IID_IExternalConnection, (void **)&g_IPtrs._pExternalConnection);
  628. assert(hresult == S_OK);
  629. hTestInterfaceThread = CreateThread(
  630. NULL, // security attributes
  631. 0, // stack size (default)
  632. (LPTHREAD_START_ROUTINE)&CreateEHTest, // address of thread function
  633. NULL, // arguments of thread function
  634. 0, // creation flags
  635. &dwThreadId ); // address of new thread ID
  636. assert(hTestInterfaceThread != NULL); //ensure that we have a valid thread handle
  637. // wait for the thread object so we can examine the exit/error code
  638. WaitForSingleObject(hTestInterfaceThread, INFINITE);
  639. GetExitCodeThread(hTestInterfaceThread, &dwThreadExitCode);
  640. hresult = (HRESULT)dwThreadExitCode;
  641. CloseHandle(hTestInterfaceThread);
  642. pCF->Release();
  643. return hresult;
  644. }
  645. //+-------------------------------------------------------------------------
  646. //
  647. // Function: GetClipBoardTest
  648. //
  649. // Synopsis: calls interface method functions and exits thread
  650. //
  651. // Effects:
  652. //
  653. // Arguments: none
  654. //
  655. // Requires:
  656. //
  657. // Returns: void
  658. //
  659. // Signals:
  660. //
  661. // Modifies:
  662. //
  663. // Algorithm:
  664. //
  665. // History: dd-mmm-yy Author Comment
  666. // 11-Jan-95 t-ScottH author
  667. //
  668. // Notes: all the interface methods are being called from a thread
  669. // which is not the owner. The methods should return
  670. // RPC_E_WRONG_THREAD error. If an interface method does not
  671. // return such error message, it is asserted and the
  672. // thread is exited with an E_UNEXPECTED exit code.
  673. //
  674. //--------------------------------------------------------------------------
  675. void GetClipboardTest(void)
  676. {
  677. DataObjectMethods();
  678. ExitThread((DWORD)NOERROR);
  679. }
  680. //+-------------------------------------------------------------------------
  681. //
  682. // Function: LinkObjectTest
  683. //
  684. // Synopsis: calls interface method functions and exits thread
  685. //
  686. // Effects:
  687. //
  688. // Arguments: none
  689. //
  690. // Requires:
  691. //
  692. // Returns: void
  693. //
  694. // Signals:
  695. //
  696. // Modifies:
  697. //
  698. // Algorithm:
  699. //
  700. // History: dd-mmm-yy Author Comment
  701. // 11-Jan-95 t-ScottH author
  702. //
  703. // Notes: all the interface methods are being called from a thread
  704. // which is not the owner. The methods should return
  705. // RPC_E_WRONG_THREAD error. If an interface method does not
  706. // return such error message, it is asserted and the
  707. // thread is exited with an E_UNEXPECTED exit code.
  708. //
  709. //--------------------------------------------------------------------------
  710. void LinkObjectTest(void)
  711. {
  712. OleObjectMethods();
  713. PersistStorageMethods();
  714. DataObjectMethods();
  715. RunnableObjectMethods();
  716. OleCache2Methods();
  717. ViewObject2Methods();
  718. OleLinkMethods();
  719. ExitThread((DWORD)NOERROR);
  720. }
  721. //+-------------------------------------------------------------------------
  722. //
  723. // Function: CreateEHTest
  724. //
  725. // Synopsis: calls interface method functions and exits thread
  726. //
  727. // Effects:
  728. //
  729. // Arguments: none
  730. //
  731. // Requires:
  732. //
  733. // Returns: void
  734. //
  735. // Signals:
  736. //
  737. // Modifies:
  738. //
  739. // Algorithm:
  740. //
  741. // History: dd-mmm-yy Author Comment
  742. // 11-Jan-95 t-ScottH author
  743. //
  744. // Notes: all the interface methods are being called from a thread
  745. // which is not the owner. The methods should return
  746. // RPC_E_WRONG_THREAD error. If an interface method does not
  747. // return such error message, it is asserted and the
  748. // thread is exited with an E_UNEXPECTED exit code.
  749. //
  750. //--------------------------------------------------------------------------
  751. void CreateEHTest(void)
  752. {
  753. ExternalConnectionsMethods();
  754. OleObjectMethods();
  755. PersistStorageMethods();
  756. DataObjectMethods();
  757. RunnableObjectMethods();
  758. ViewObject2Methods();
  759. OleCache2Methods();
  760. ExitThread((DWORD)NOERROR);
  761. }
  762. //+-------------------------------------------------------------------------
  763. //
  764. // Function: OleLinkMethods
  765. //
  766. // Synopsis: Calls all public IOleLink interface methods with NULL
  767. // parameters.
  768. //
  769. // Effects:
  770. //
  771. // Arguments: none
  772. //
  773. // Requires:
  774. //
  775. // Returns: void
  776. //
  777. // Signals:
  778. //
  779. // Modifies:
  780. //
  781. // Algorithm:
  782. //
  783. // History: dd-mmm-yy Author Comment
  784. // 11-Jan-95 t-ScottH author
  785. //
  786. // Notes: The interface methods are called on the wrong thread, thus
  787. // an RPC_E_WRONG_THREAD error should be returned from each
  788. // method. If not, we assert and then exit the thread.
  789. //
  790. //--------------------------------------------------------------------------
  791. void OleLinkMethods(void)
  792. {
  793. HRESULT hresult;
  794. hresult = g_IPtrs._pOleLink->SetUpdateOptions(NULL);
  795. CHECK_FOR_THREAD_ERROR(hresult);
  796. hresult = g_IPtrs._pOleLink->GetUpdateOptions(NULL);
  797. CHECK_FOR_THREAD_ERROR(hresult);
  798. hresult = g_IPtrs._pOleLink->SetSourceMoniker(NULL, CLSID_NULL);
  799. CHECK_FOR_THREAD_ERROR(hresult);
  800. hresult = g_IPtrs._pOleLink->GetSourceMoniker(NULL);
  801. CHECK_FOR_THREAD_ERROR(hresult);
  802. hresult = g_IPtrs._pOleLink->SetSourceDisplayName(NULL);
  803. CHECK_FOR_THREAD_ERROR(hresult);
  804. hresult = g_IPtrs._pOleLink->GetSourceDisplayName(NULL);
  805. CHECK_FOR_THREAD_ERROR(hresult);
  806. hresult = g_IPtrs._pOleLink->BindToSource(NULL, NULL);
  807. CHECK_FOR_THREAD_ERROR(hresult);
  808. hresult = g_IPtrs._pOleLink->BindIfRunning();
  809. CHECK_FOR_THREAD_ERROR(hresult);
  810. hresult = g_IPtrs._pOleLink->GetBoundSource(NULL);
  811. CHECK_FOR_THREAD_ERROR(hresult);
  812. hresult = g_IPtrs._pOleLink->UnbindSource();
  813. CHECK_FOR_THREAD_ERROR(hresult);
  814. hresult = g_IPtrs._pOleLink->Update(NULL);
  815. CHECK_FOR_THREAD_ERROR(hresult);
  816. return;
  817. }
  818. //+-------------------------------------------------------------------------
  819. //
  820. // Function: ExternalConnectionsMethods
  821. //
  822. // Synopsis: Calls all public IExternalConnection interface methods with NULL
  823. // parameters.
  824. //
  825. // Effects:
  826. //
  827. // Arguments: none
  828. //
  829. // Requires:
  830. //
  831. // Returns: void
  832. //
  833. // Signals:
  834. //
  835. // Modifies:
  836. //
  837. // Algorithm:
  838. //
  839. // History: dd-mmm-yy Author Comment
  840. // 11-Jan-95 t-ScottH author
  841. //
  842. // Notes: The interface methods are called on the wrong thread, thus
  843. // an RPC_E_WRONG_THREAD error should be returned from each
  844. // method. If not, we assert and then exit the thread.
  845. //
  846. //--------------------------------------------------------------------------
  847. void ExternalConnectionsMethods(void)
  848. {
  849. HRESULT hresult;
  850. hresult = (HRESULT)g_IPtrs._pExternalConnection->AddConnection(NULL, NULL);
  851. CHECK_FOR_THREAD_ERROR(hresult);
  852. hresult = (HRESULT)g_IPtrs._pExternalConnection->ReleaseConnection(NULL, NULL, NULL);
  853. CHECK_FOR_THREAD_ERROR(hresult);
  854. return;
  855. }
  856. //+-------------------------------------------------------------------------
  857. //
  858. // Function: OleObjectMethods
  859. //
  860. // Synopsis: Calls all public IOleObject interface methods with NULL
  861. // parameters.
  862. //
  863. // Effects:
  864. //
  865. // Arguments: none
  866. //
  867. // Requires:
  868. //
  869. // Returns: void
  870. //
  871. // Signals:
  872. //
  873. // Modifies:
  874. //
  875. // Algorithm:
  876. //
  877. // History: dd-mmm-yy Author Comment
  878. // 11-Jan-95 t-ScottH author
  879. //
  880. // Notes: The interface methods are called on the wrong thread, thus
  881. // an RPC_E_WRONG_THREAD error should be returned from each
  882. // method. If not, we assert and then exit the thread.
  883. //
  884. //--------------------------------------------------------------------------
  885. void OleObjectMethods(void)
  886. {
  887. HRESULT hresult;
  888. hresult = g_IPtrs._pOleObject->SetClientSite(NULL);
  889. CHECK_FOR_THREAD_ERROR(hresult);
  890. hresult = g_IPtrs._pOleObject->GetClientSite(NULL);
  891. CHECK_FOR_THREAD_ERROR(hresult);
  892. hresult = g_IPtrs._pOleObject->SetHostNames(NULL, NULL);
  893. CHECK_FOR_THREAD_ERROR(hresult);
  894. hresult = g_IPtrs._pOleObject->Close(NULL);
  895. CHECK_FOR_THREAD_ERROR(hresult);
  896. hresult = g_IPtrs._pOleObject->SetMoniker(NULL, NULL);
  897. CHECK_FOR_THREAD_ERROR(hresult);
  898. hresult = g_IPtrs._pOleObject->GetMoniker(NULL, NULL, NULL);
  899. CHECK_FOR_THREAD_ERROR(hresult);
  900. hresult = g_IPtrs._pOleObject->InitFromData(NULL, NULL, NULL);
  901. CHECK_FOR_THREAD_ERROR(hresult);
  902. hresult = g_IPtrs._pOleObject->GetClipboardData(NULL, NULL);
  903. CHECK_FOR_THREAD_ERROR(hresult);
  904. hresult = g_IPtrs._pOleObject->DoVerb(NULL, NULL, NULL, NULL, NULL, NULL);
  905. CHECK_FOR_THREAD_ERROR(hresult);
  906. hresult = g_IPtrs._pOleObject->EnumVerbs(NULL);
  907. CHECK_FOR_THREAD_ERROR(hresult);
  908. hresult = g_IPtrs._pOleObject->Update();
  909. CHECK_FOR_THREAD_ERROR(hresult);
  910. hresult = g_IPtrs._pOleObject->IsUpToDate();
  911. CHECK_FOR_THREAD_ERROR(hresult);
  912. hresult = g_IPtrs._pOleObject->GetUserClassID(NULL);
  913. CHECK_FOR_THREAD_ERROR(hresult);
  914. hresult = g_IPtrs._pOleObject->GetUserType(NULL, NULL);
  915. CHECK_FOR_THREAD_ERROR(hresult);
  916. hresult = g_IPtrs._pOleObject->SetExtent(NULL, NULL);
  917. CHECK_FOR_THREAD_ERROR(hresult);
  918. hresult = g_IPtrs._pOleObject->GetExtent(NULL, NULL);
  919. CHECK_FOR_THREAD_ERROR(hresult);
  920. hresult = g_IPtrs._pOleObject->Advise(NULL, NULL);
  921. CHECK_FOR_THREAD_ERROR(hresult);
  922. hresult = g_IPtrs._pOleObject->Unadvise(NULL);
  923. CHECK_FOR_THREAD_ERROR(hresult);
  924. hresult = g_IPtrs._pOleObject->EnumAdvise(NULL);
  925. CHECK_FOR_THREAD_ERROR(hresult);
  926. hresult = g_IPtrs._pOleObject->GetMiscStatus(NULL, NULL);
  927. CHECK_FOR_THREAD_ERROR(hresult);
  928. hresult = g_IPtrs._pOleObject->SetColorScheme(NULL);
  929. CHECK_FOR_THREAD_ERROR(hresult);
  930. return;
  931. }
  932. //+-------------------------------------------------------------------------
  933. //
  934. // Function: PersistStorageMethods
  935. //
  936. // Synopsis: Calls all public IPersistStorage interface methods with NULL
  937. // parameters.
  938. //
  939. // Effects:
  940. //
  941. // Arguments: none
  942. //
  943. // Requires:
  944. //
  945. // Returns: void
  946. //
  947. // Signals:
  948. //
  949. // Modifies:
  950. //
  951. // Algorithm:
  952. //
  953. // History: dd-mmm-yy Author Comment
  954. // 11-Jan-95 t-ScottH author
  955. //
  956. // Notes: The interface methods are called on the wrong thread, thus
  957. // an RPC_E_WRONG_THREAD error should be returned from each
  958. // method. If not, we assert and then exit the thread.
  959. //
  960. //--------------------------------------------------------------------------
  961. void PersistStorageMethods(void)
  962. {
  963. HRESULT hresult;
  964. hresult = g_IPtrs._pPersistStorage->GetClassID(NULL);
  965. CHECK_FOR_THREAD_ERROR(hresult);
  966. hresult = g_IPtrs._pPersistStorage->IsDirty();
  967. CHECK_FOR_THREAD_ERROR(hresult);
  968. hresult = g_IPtrs._pPersistStorage->InitNew(NULL);
  969. CHECK_FOR_THREAD_ERROR(hresult);
  970. hresult = g_IPtrs._pPersistStorage->Load(NULL);
  971. CHECK_FOR_THREAD_ERROR(hresult);
  972. hresult = g_IPtrs._pPersistStorage->Save(NULL, NULL);
  973. CHECK_FOR_THREAD_ERROR(hresult);
  974. hresult = g_IPtrs._pPersistStorage->SaveCompleted(NULL);
  975. CHECK_FOR_THREAD_ERROR(hresult);
  976. hresult = g_IPtrs._pPersistStorage->HandsOffStorage();
  977. CHECK_FOR_THREAD_ERROR(hresult);
  978. return;
  979. }
  980. //+-------------------------------------------------------------------------
  981. //
  982. // Function: DataObjectMethods
  983. //
  984. // Synopsis: Calls all public IDataObject interface methods with NULL
  985. // parameters.
  986. //
  987. // Effects:
  988. //
  989. // Arguments: none
  990. //
  991. // Requires:
  992. //
  993. // Returns: void
  994. //
  995. // Signals:
  996. //
  997. // Modifies:
  998. //
  999. // Algorithm:
  1000. //
  1001. // History: dd-mmm-yy Author Comment
  1002. // 11-Jan-95 t-ScottH author
  1003. //
  1004. // Notes: The interface methods are called on the wrong thread, thus
  1005. // an RPC_E_WRONG_THREAD error should be returned from each
  1006. // method. If not, we assert and then exit the thread.
  1007. //
  1008. //--------------------------------------------------------------------------
  1009. void DataObjectMethods(void)
  1010. {
  1011. HRESULT hresult;
  1012. hresult = g_IPtrs._pDataObject->GetData(NULL, NULL);
  1013. CHECK_FOR_THREAD_ERROR(hresult);
  1014. hresult = g_IPtrs._pDataObject->GetDataHere(NULL, NULL);
  1015. CHECK_FOR_THREAD_ERROR(hresult);
  1016. hresult = g_IPtrs._pDataObject->QueryGetData(NULL);
  1017. CHECK_FOR_THREAD_ERROR(hresult);
  1018. hresult = g_IPtrs._pDataObject->GetCanonicalFormatEtc(NULL, NULL);
  1019. CHECK_FOR_THREAD_ERROR(hresult);
  1020. hresult = g_IPtrs._pDataObject->SetData(NULL, NULL, NULL);
  1021. CHECK_FOR_THREAD_ERROR(hresult);
  1022. hresult = g_IPtrs._pDataObject->EnumFormatEtc(NULL, NULL);
  1023. CHECK_FOR_THREAD_ERROR(hresult);
  1024. hresult = g_IPtrs._pDataObject->DAdvise(NULL, NULL, NULL, NULL);
  1025. CHECK_FOR_THREAD_ERROR(hresult);
  1026. hresult = g_IPtrs._pDataObject->DUnadvise(NULL);
  1027. CHECK_FOR_THREAD_ERROR(hresult);
  1028. hresult = g_IPtrs._pDataObject->EnumDAdvise(NULL);
  1029. CHECK_FOR_THREAD_ERROR(hresult);
  1030. return;
  1031. }
  1032. //+-------------------------------------------------------------------------
  1033. //
  1034. // Function: RunnableObjectMethods
  1035. //
  1036. // Synopsis: Calls all public IRunnableObject interface methods with NULL
  1037. // parameters.
  1038. //
  1039. // Effects:
  1040. //
  1041. // Arguments: none
  1042. //
  1043. // Requires:
  1044. //
  1045. // Returns: void
  1046. //
  1047. // Signals:
  1048. //
  1049. // Modifies:
  1050. //
  1051. // Algorithm:
  1052. //
  1053. // History: dd-mmm-yy Author Comment
  1054. // 11-Jan-95 t-ScottH author
  1055. //
  1056. // Notes: The interface methods are called on the wrong thread, thus
  1057. // an RPC_E_WRONG_THREAD error should be returned from each
  1058. // method. If not, we assert and then exit the thread.
  1059. //
  1060. //--------------------------------------------------------------------------
  1061. void RunnableObjectMethods(void)
  1062. {
  1063. HRESULT hresult;
  1064. hresult = g_IPtrs._pRunnableObject->GetRunningClass(NULL);
  1065. CHECK_FOR_THREAD_ERROR(hresult);
  1066. hresult = g_IPtrs._pRunnableObject->Run(NULL);
  1067. CHECK_FOR_THREAD_ERROR(hresult);
  1068. hresult = g_IPtrs._pRunnableObject->IsRunning();
  1069. CHECK_FOR_THREAD_ERROR(hresult);
  1070. hresult = g_IPtrs._pRunnableObject->LockRunning(NULL, NULL);
  1071. CHECK_FOR_THREAD_ERROR(hresult);
  1072. hresult = g_IPtrs._pRunnableObject->SetContainedObject(NULL);
  1073. CHECK_FOR_THREAD_ERROR(hresult);
  1074. return;
  1075. }
  1076. //+-------------------------------------------------------------------------
  1077. //
  1078. // Function: ViewObject2Methods
  1079. //
  1080. // Synopsis: Calls all public IViewObject2 interface methods with NULL
  1081. // parameters.
  1082. //
  1083. // Effects:
  1084. //
  1085. // Arguments: none
  1086. //
  1087. // Requires:
  1088. //
  1089. // Returns: void
  1090. //
  1091. // Signals:
  1092. //
  1093. // Modifies:
  1094. //
  1095. // Algorithm:
  1096. //
  1097. // History: dd-mmm-yy Author Comment
  1098. // 11-Jan-95 t-ScottH author
  1099. //
  1100. // Notes: The interface methods are called on the wrong thread, thus
  1101. // an RPC_E_WRONG_THREAD error should be returned from each
  1102. // method. If not, we assert and then exit the thread.
  1103. //
  1104. //--------------------------------------------------------------------------
  1105. void ViewObject2Methods(void)
  1106. {
  1107. HRESULT hresult;
  1108. hresult = g_IPtrs._pViewObject2->Draw(NULL, NULL, NULL, NULL, NULL,
  1109. NULL, NULL, NULL, NULL, NULL);
  1110. CHECK_FOR_THREAD_ERROR(hresult);
  1111. hresult = g_IPtrs._pViewObject2->GetColorSet(NULL, NULL, NULL, NULL, NULL, NULL);
  1112. CHECK_FOR_THREAD_ERROR(hresult);
  1113. hresult = g_IPtrs._pViewObject2->Freeze(NULL, NULL, NULL, NULL);
  1114. CHECK_FOR_THREAD_ERROR(hresult);
  1115. hresult = g_IPtrs._pViewObject2->Unfreeze(NULL);
  1116. CHECK_FOR_THREAD_ERROR(hresult);
  1117. hresult = g_IPtrs._pViewObject2->SetAdvise(NULL, NULL, NULL);
  1118. CHECK_FOR_THREAD_ERROR(hresult);
  1119. hresult = g_IPtrs._pViewObject2->GetAdvise(NULL, NULL, NULL);
  1120. CHECK_FOR_THREAD_ERROR(hresult);
  1121. hresult = g_IPtrs._pViewObject2->GetExtent(NULL, NULL, NULL, NULL);
  1122. CHECK_FOR_THREAD_ERROR(hresult);
  1123. return;
  1124. }
  1125. //+-------------------------------------------------------------------------
  1126. //
  1127. // Function: OleCache2Methods
  1128. //
  1129. // Synopsis: Calls all public IOleCache2 interface methods with NULL
  1130. // parameters.
  1131. //
  1132. // Effects:
  1133. //
  1134. // Arguments: none
  1135. //
  1136. // Requires:
  1137. //
  1138. // Returns: void
  1139. //
  1140. // Signals:
  1141. //
  1142. // Modifies:
  1143. //
  1144. // Algorithm:
  1145. //
  1146. // History: dd-mmm-yy Author Comment
  1147. // 11-Jan-95 t-ScottH author
  1148. //
  1149. // Notes:
  1150. // Notes: The interface methods are called on the wrong thread, thus
  1151. // an RPC_E_WRONG_THREAD error should be returned from each
  1152. // method. If not, we assert and then exit the thread.
  1153. //
  1154. //--------------------------------------------------------------------------
  1155. void OleCache2Methods(void)
  1156. {
  1157. HRESULT hresult;
  1158. hresult = g_IPtrs._pOleCache2->Cache(NULL, NULL, NULL);
  1159. CHECK_FOR_THREAD_ERROR(hresult);
  1160. hresult = g_IPtrs._pOleCache2->Uncache(NULL);
  1161. CHECK_FOR_THREAD_ERROR(hresult);
  1162. hresult = g_IPtrs._pOleCache2->EnumCache(NULL);
  1163. CHECK_FOR_THREAD_ERROR(hresult);
  1164. hresult = g_IPtrs._pOleCache2->InitCache(NULL);
  1165. CHECK_FOR_THREAD_ERROR(hresult);
  1166. hresult = g_IPtrs._pOleCache2->SetData(NULL, NULL, NULL);
  1167. CHECK_FOR_THREAD_ERROR(hresult);
  1168. hresult = g_IPtrs._pOleCache2->UpdateCache(NULL, NULL, NULL);
  1169. CHECK_FOR_THREAD_ERROR(hresult);
  1170. hresult = g_IPtrs._pOleCache2->DiscardCache(NULL);
  1171. CHECK_FOR_THREAD_ERROR(hresult);
  1172. return;
  1173. }