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.

652 lines
21 KiB

  1. '****************************************************************
  2. '* MMC automation / com event test script
  3. '*
  4. '* Copyright (C) Microsoft Corporation, 2000 - 2000
  5. '****************************************************************
  6. Option Explicit ' Force explicit variable declaration.
  7. '****************************************************************
  8. '* Event Handlers : Application
  9. '****************************************************************
  10. Dim ErrorInEvent
  11. ErrorInEvent = False
  12. '---------------------------------------------
  13. ' Occurs when application is closed
  14. '---------------------------------------------
  15. Dim AppEvent_OnQuit_Application
  16. Dim AppEvent_OnQuit_IsExpected
  17. Sub AppEvent_OnQuit( Application )
  18. if Not AppEvent_OnQuit_IsExpected Then
  19. ErrorInEvent = True
  20. Err.Raise 100, "AppEvent_OnQuit", "Event occured when not expected"
  21. End if
  22. Set AppEvent_OnQuit_Application = Application
  23. Err.Raise 222, "--Not a bug--", "Returning error to test if script does not break MMC"
  24. End Sub
  25. '---------------------------------------------
  26. ' Occurs when document is opened
  27. '---------------------------------------------
  28. Dim AppEvent_OnDocumentOpen_Document
  29. Dim AppEvent_OnDocumentOpen_bNew
  30. Dim AppEvent_OnDocumentOpen_IsExpected
  31. Sub AppEvent_OnDocumentOpen( Document, bNew )
  32. if Not AppEvent_OnDocumentOpen_IsExpected Then
  33. ErrorInEvent = True
  34. Err.Raise 100, "AppEvent_OnDocumentOpen", "Event occured when not expected"
  35. End if
  36. Set AppEvent_OnDocumentOpen_Document = Document
  37. AppEvent_OnDocumentOpen_bNew = bNew
  38. Err.Raise 222, "--Not a bug--", "Returning error to test if script does not break MMC"
  39. End Sub
  40. '****************************************************************
  41. '* Event Handlers : Document
  42. '****************************************************************
  43. '---------------------------------------------
  44. ' Occurs before the document is destroyed
  45. '---------------------------------------------
  46. Dim AppEvent_OnDocumentClose_Document
  47. Dim AppEvent_OnDocumentClose_IsExpected
  48. Sub AppEvent_OnDocumentClose( Document)
  49. if Not AppEvent_OnDocumentClose_IsExpected Then
  50. ErrorInEvent = True
  51. Err.Raise 100, "AppEvent_OnDocumentClose", "Event occured when not expected"
  52. End if
  53. Set AppEvent_OnDocumentClose_Document = Document
  54. Err.Raise 222, "--Not a bug--", "Returning error to test if script does not break MMC"
  55. End Sub
  56. '---------------------------------------------
  57. ' Occurs when a snapin is added
  58. '---------------------------------------------
  59. Dim AppEvent_OnSnapInAdded_Document
  60. Dim AppEvent_OnSnapInAdded_SnapIn
  61. Dim AppEvent_OnSnapInAdded_IsExpected
  62. Sub AppEvent_OnSnapInAdded( Document, SnapIn )
  63. if Not AppEvent_OnSnapInAdded_IsExpected Then
  64. ErrorInEvent = True
  65. Err.Raise 100, "AppEvent_OnSnapInAdded", "Event occured when not expected"
  66. End if
  67. Set AppEvent_OnSnapInAdded_Document = Document
  68. Set AppEvent_OnSnapInAdded_SnapIn = SnapIn
  69. Err.Raise 222, "--Not a bug--", "Returning error to test if script does not break MMC"
  70. End Sub
  71. '---------------------------------------------
  72. ' Occurs when the snapin is removed
  73. '---------------------------------------------
  74. Dim AppEvent_OnSnapInRemoved_Document
  75. Dim AppEvent_OnSnapInRemoved_SnapIn
  76. Dim AppEvent_OnSnapInRemoved_IsExpected
  77. Sub AppEvent_OnSnapInRemoved( Document, SnapIn )
  78. if Not AppEvent_OnSnapInRemoved_IsExpected Then
  79. ErrorInEvent = True
  80. Err.Raise 100, "AppEvent_OnSnapInRemoved", "Event occured when not expected"
  81. End if
  82. Set AppEvent_OnSnapInRemoved_Document = Document
  83. Set AppEvent_OnSnapInRemoved_SnapIn = SnapIn
  84. Err.Raise 222, "--Not a bug--", "Returning error to test if script does not break MMC"
  85. End Sub
  86. '---------------------------------------------
  87. ' Occurs when a view is added
  88. '---------------------------------------------
  89. Dim AppEvent_OnNewView_View
  90. Dim AppEvent_OnNewView_IsExpected
  91. Sub AppEvent_OnNewView( View )
  92. if Not AppEvent_OnNewView_IsExpected Then
  93. ErrorInEvent = True
  94. Err.Raise 100, "AppEvent_OnNewView", "Event occured when not expected"
  95. End if
  96. Set AppEvent_OnNewView_View = View
  97. Err.Raise 222, "--Not a bug--", "Returning error to test if script does not break MMC"
  98. End Sub
  99. '---------------------------------------------
  100. ' Occurs when the view is destroyed
  101. '---------------------------------------------
  102. Dim AppEvent_OnViewClose_View
  103. Dim AppEvent_OnViewClose_IsExpected
  104. Sub AppEvent_OnViewClose( View )
  105. if Not AppEvent_OnViewClose_IsExpected Then
  106. ErrorInEvent = True
  107. Err.Raise 100, "AppEvent_OnViewClose", "Event occured when not expected"
  108. End if
  109. Set AppEvent_OnViewClose_View = View
  110. Err.Raise 222, "--Not a bug--", "Returning error to test if script does not break MMC"
  111. End Sub
  112. '---------------------------------------------
  113. ' Occurs when the view is changed, for instance by a scope node selection change
  114. '---------------------------------------------
  115. Dim AppEvent_OnViewChange_View
  116. Dim AppEvent_OnViewChange_NewOwnerNode
  117. Dim AppEvent_OnViewChange_IsExpected
  118. Sub AppEvent_OnViewChange( View, NewOwnerNode )
  119. if Not AppEvent_OnViewChange_IsExpected Then
  120. ErrorInEvent = True
  121. Err.Raise 100, "AppEvent_OnViewChange", "Event occured when not expected"
  122. End if
  123. Set AppEvent_OnViewChange_View = View
  124. Set AppEvent_OnViewChange_NewOwnerNode = NewOwnerNode
  125. Err.Raise 222, "--Not a bug--", "Returning error to test if script does not break MMC"
  126. End Sub
  127. '---------------------------------------------
  128. ' Occurs when the result item selection for a view is changed
  129. '---------------------------------------------
  130. Dim AppEvent_OnSelectionChange_View
  131. Dim AppEvent_OnSelectionChange_NewNodes
  132. Dim AppEvent_OnSelectionChange_IsExpected
  133. Sub AppEvent_OnSelectionChange( View, NewNodes )
  134. if Not AppEvent_OnSelectionChange_IsExpected Then
  135. ErrorInEvent = True
  136. Err.Raise 100, "AppEvent_OnSelectionChange", "Event occured when not expected"
  137. End if
  138. Set AppEvent_OnSelectionChange_View = View
  139. Set AppEvent_OnSelectionChange_NewNodes = NewNodes
  140. Err.Raise 222, "--Not a bug--", "Returning error to test if script does not break MMC"
  141. End Sub
  142. '---------------------------------------------
  143. ' Occurs when a context menu for a selection is created
  144. '---------------------------------------------
  145. Dim AppEvent_OnCreateContextMenu_View
  146. Dim AppEvent_OnCreateContextMenu_Nodes
  147. Dim AppEvent_OnCreateContextMenu_Menu
  148. Dim AppEvent_OnCreateContextMenu_IsExpected
  149. Sub AppEvent_OnCreateContextMenu( View, Nodes, Menu )
  150. if Not AppEvent_OnCreateContextMenu_IsExpected Then
  151. ErrorInEvent = True
  152. Err.Raise 100, "AppEvent_OnCreateContextMenu", "Event occured when not expected"
  153. End if
  154. Set AppEvent_OnCreateContextMenu_View = View
  155. Set AppEvent_OnCreateContextMenu_Nodes = Nodes
  156. Set AppEvent_OnCreateContextMenu_Menu = Menu
  157. Err.Raise 222, "--Not a bug--", "Returning error to test if script does not break MMC"
  158. End Sub
  159. '---------------------------------------------
  160. ' Occurs when a context menu item is executed
  161. '---------------------------------------------
  162. Dim AppEvent_OnContextMenuExecuted_IsExpected
  163. Sub AppEvent_OnContextMenuExecuted( )
  164. if Not AppEvent_OnContextMenuExecuted_IsExpected Then
  165. ErrorInEvent = True
  166. Err.Raise 100, "AppEvent_OnContextMenuExecuted", "Event occured when not expected"
  167. End if
  168. Err.Raise 222, "--Not a bug--", "Returning error to test if script does not break MMC"
  169. End Sub
  170. '****************************************************************
  171. '* Test Steps
  172. '****************************************************************
  173. '---------------------------------------------
  174. ' test step 1: Document open/save/new/close operations
  175. '---------------------------------------------
  176. Sub TestStep1 (app)
  177. WScript.Echo "test step 1: Document operations"
  178. '- - - - - - - - - - - - - - - - - - - - - - -
  179. ' save the document
  180. '- - - - - - - - - - - - - - - - - - - - - - -
  181. Dim console_path
  182. console_path = "c:\mmc_test_console.msc"
  183. app.Document.SaveAs console_path
  184. If 0 <> StrComp(app.Document.Name, console_path, 1) Then '**BUGBUG** Or Not app.Document.IsSaved Then
  185. Err.Raise 100, "TestStep1", "Failed save document: " + app.Document.Name
  186. End If
  187. '- - - - - - - - - - - - - - - - - - - - - - -
  188. ' close the document
  189. '- - - - - - - - - - - - - - - - - - - - - - -
  190. Dim doc
  191. Set doc = app.Document
  192. Set AppEvent_OnDocumentClose_Document = Nothing
  193. AppEvent_OnDocumentClose_IsExpected = True
  194. AppEvent_OnSelectionChange_IsExpected = True
  195. doc.Close False
  196. AppEvent_OnSelectionChange_IsExpected = False
  197. AppEvent_OnDocumentClose_IsExpected = False
  198. '- - - - - - - - - - - - - - - - - - - - - - -
  199. ' see if we've got a close event
  200. '- - - - - - - - - - - - - - - - - - - - - - -
  201. If Not AppEvent_OnDocumentClose_Document Is doc Then
  202. Err.Raise 100, "TestStep1", "Failed to catch close event"
  203. End If
  204. '- - - - - - - - - - - - - - - - - - - - - - -
  205. ' create a new document
  206. '- - - - - - - - - - - - - - - - - - - - - - -
  207. Set AppEvent_OnDocumentOpen_Document = Nothing
  208. AppEvent_OnDocumentOpen_IsExpected = True
  209. '**BUGBUG** "No method to create the new document" app.NewDocument
  210. AppEvent_OnDocumentOpen_IsExpected = False
  211. 'if doc Is app.Document Then
  212. ' Err.Raise 100, "TestStep1", "Failed to create a new document"
  213. 'End If
  214. 'if Not AppEvent_OnDocumentOpen_Document Is app.Document Then
  215. ' Err.Raise 100, "TestStep1", "Failed to catch open event"
  216. 'End If
  217. 'if Not AppEvent_OnDocumentOpen_bNew then
  218. ' Err.Raise 100, "TestStep1", "Document incorrectly reported as loaded from file"
  219. 'End If
  220. '- - - - - - - - - - - - - - - - - - - - - - -
  221. ' close the document again
  222. '- - - - - - - - - - - - - - - - - - - - - - -
  223. 'Set doc = app.Document
  224. 'Set AppEvent_OnDocumentClose_Document = Nothing
  225. 'AppEvent_OnDocumentClose_IsExpected = True
  226. 'doc.Close False
  227. 'AppEvent_OnDocumentClose_IsExpected = False
  228. '- - - - - - - - - - - - - - - - - - - - - - -
  229. ' see if we've got a close event
  230. '- - - - - - - - - - - - - - - - - - - - - - -
  231. 'If Not AppEvent_OnDocumentClose_Document Is doc Then
  232. ' Err.Raise 100, "TestStep1", "Failed to catch close event"
  233. 'End If
  234. '- - - - - - - - - - - - - - - - - - - - - - -
  235. ' open a document
  236. '- - - - - - - - - - - - - - - - - - - - - - -
  237. Set AppEvent_OnDocumentOpen_Document = Nothing
  238. AppEvent_OnDocumentOpen_IsExpected = True
  239. AppEvent_OnSelectionChange_IsExpected = True '**BUGBUG**
  240. AppEvent_OnViewChange_IsExpected = True '**BUGBUG**
  241. AppEvent_OnNewView_IsExpected = True '**BUGBUG**
  242. app.Load console_path
  243. AppEvent_OnNewView_IsExpected = False
  244. AppEvent_OnViewChange_IsExpected = False
  245. AppEvent_OnSelectionChange_IsExpected = False
  246. AppEvent_OnDocumentOpen_IsExpected = False
  247. if doc Is app.Document Then
  248. Err.Raise 100, "TestStep1", "Failed to open a document"
  249. End If
  250. if Not AppEvent_OnDocumentOpen_Document Is app.Document Then
  251. Err.Raise 100, "TestStep1", "Failed to catch open event"
  252. End If
  253. if AppEvent_OnDocumentOpen_Document Is doc Then
  254. Err.Raise 100, "TestStep1", "Wrong document cought in Open event"
  255. End If
  256. if AppEvent_OnDocumentOpen_bNew then
  257. Err.Raise 100, "TestStep1", "Document incorrectly reported as new"
  258. End If
  259. '- - - - - - - - - - - - - - - - - - - - - - -
  260. ' small cleanup
  261. '- - - - - - - - - - - - - - - - - - - - - - -
  262. Set AppEvent_OnDocumentClose_Document = Nothing
  263. Set AppEvent_OnDocumentOpen_Document = Nothing
  264. WScript.Echo "test step 1: complete"
  265. End Sub
  266. '---------------------------------------------
  267. ' test step 2: Snapin add/remove operations
  268. '---------------------------------------------
  269. Sub TestStep2 (app)
  270. WScript.Echo "test step 2: Snapin operations"
  271. '- - - - - - - - - - - - - - - - - - - - - - -
  272. ' add the snapin
  273. '- - - - - - - - - - - - - - - - - - - - - - -
  274. Set AppEvent_OnSnapInAdded_Document = Nothing
  275. Set AppEvent_OnSnapInAdded_SnapIn = Nothing
  276. Dim FolderSnapin
  277. FolderSnapin = "{C96401CC-0E17-11D3-885B-00C04F72C717}"
  278. Dim Snapin1
  279. AppEvent_OnSnapInAdded_IsExpected = True
  280. AppEvent_OnSelectionChange_IsExpected = True '**BUGBUG**
  281. AppEvent_OnViewChange_IsExpected = True '**BUGBUG**
  282. set Snapin1 = app.Document.Snapins.Add(FolderSnapin)
  283. AppEvent_OnViewChange_IsExpected = False
  284. AppEvent_OnSelectionChange_IsExpected = False
  285. AppEvent_OnSnapInAdded_IsExpected = False
  286. if IsNull(Snapin1) Then
  287. Err.Raise 100, "TestStep2", "Failed to create snapin"
  288. End If
  289. if Not AppEvent_OnSnapInAdded_Document is app.Document Or Not AppEvent_OnSnapInAdded_SnapIn Is Snapin1 Then
  290. Err.Raise 100, "TestStep2", "Failed to catch AddSnapin event"
  291. End If
  292. '- - - - - - - - - - - - - - - - - - - - - - -
  293. ' add the snapin #2
  294. '- - - - - - - - - - - - - - - - - - - - - - -
  295. Set AppEvent_OnSnapInAdded_Document = Nothing
  296. Set AppEvent_OnSnapInAdded_SnapIn = Nothing
  297. Dim Snapin2
  298. AppEvent_OnSnapInAdded_IsExpected = True
  299. AppEvent_OnSelectionChange_IsExpected = True '**BUGBUG**
  300. AppEvent_OnViewChange_IsExpected = True '**BUGBUG**
  301. set Snapin2 = app.Document.Snapins.Add(FolderSnapin) '**BUGBUG** Snapin1) ' as child of Snapin1
  302. AppEvent_OnViewChange_IsExpected = False
  303. AppEvent_OnSelectionChange_IsExpected = False
  304. AppEvent_OnSnapInAdded_IsExpected = False
  305. if IsNull(Snapin2) Then
  306. Err.Raise 100, "TestStep2", "Failed to create snapin #2"
  307. End If
  308. if Not AppEvent_OnSnapInAdded_Document is app.Document Or Not AppEvent_OnSnapInAdded_SnapIn Is Snapin2 Then
  309. Err.Raise 100, "TestStep2", "Failed to catch AddSnapin #2 event"
  310. End If
  311. '- - - - - - - - - - - - - - - - - - - - - - -
  312. ' remove the snapin #2
  313. '- - - - - - - - - - - - - - - - - - - - - - -
  314. Set AppEvent_OnSnapInRemoved_Document = Nothing
  315. Set AppEvent_OnSnapInRemoved_SnapIn = Nothing
  316. AppEvent_OnSnapInRemoved_IsExpected = True
  317. AppEvent_OnSelectionChange_IsExpected = True '**BUGBUG**
  318. AppEvent_OnViewChange_IsExpected = True '**BUGBUG**
  319. app.Document.Snapins.Remove Snapin2
  320. AppEvent_OnViewChange_IsExpected = False
  321. AppEvent_OnSelectionChange_IsExpected = False
  322. AppEvent_OnSnapInRemoved_IsExpected = False
  323. if Not AppEvent_OnSnapInRemoved_Document is app.Document Or Not AppEvent_OnSnapInRemoved_SnapIn Is Snapin2 Then
  324. Err.Raise 100, "TestStep2", "Failed to catch RemoveSnapin #2 event"
  325. End If
  326. set Snapin2 = Nothing
  327. '- - - - - - - - - - - - - - - - - - - - - - -
  328. ' remove the snapin #1
  329. '- - - - - - - - - - - - - - - - - - - - - - -
  330. Set AppEvent_OnSnapInRemoved_Document = Nothing
  331. Set AppEvent_OnSnapInRemoved_SnapIn = Nothing
  332. AppEvent_OnSnapInRemoved_IsExpected = True
  333. AppEvent_OnSelectionChange_IsExpected = True '**BUGBUG**
  334. AppEvent_OnViewChange_IsExpected = True '**BUGBUG**
  335. app.Document.Snapins.Remove Snapin1
  336. AppEvent_OnViewChange_IsExpected = False
  337. AppEvent_OnSelectionChange_IsExpected = False
  338. AppEvent_OnSnapInRemoved_IsExpected = False
  339. if Not AppEvent_OnSnapInRemoved_Document is app.Document Or Not AppEvent_OnSnapInRemoved_SnapIn Is Snapin1 Then
  340. Err.Raise 100, "TestStep2", "Failed to catch RemoveSnapin event"
  341. End If
  342. '- - - - - - - - - - - - - - - - - - - - - - -
  343. ' re-add them to have test something to run test on
  344. '- - - - - - - - - - - - - - - - - - - - - - -
  345. AppEvent_OnSnapInAdded_IsExpected = True
  346. AppEvent_OnSelectionChange_IsExpected = True '**BUGBUG**
  347. AppEvent_OnViewChange_IsExpected = True '**BUGBUG**
  348. set Snapin1 = app.Document.Snapins.Add(FolderSnapin)
  349. set Snapin2 = app.Document.Snapins.Add(FolderSnapin) '**BUGBUG** Snapin1) ' as child of Snapin1
  350. AppEvent_OnViewChange_IsExpected = False
  351. AppEvent_OnSelectionChange_IsExpected = False
  352. AppEvent_OnSnapInAdded_IsExpected = False
  353. set Snapin1 = Nothing
  354. set Snapin2 = Nothing
  355. Set AppEvent_OnSnapInRemoved_Document = Nothing
  356. Set AppEvent_OnSnapInRemoved_SnapIn = Nothing
  357. Set AppEvent_OnSnapInAdded_Document = Nothing
  358. Set AppEvent_OnSnapInAdded_SnapIn = Nothing
  359. WScript.Echo "test step 2: complete"
  360. End Sub
  361. '---------------------------------------------
  362. ' test step 3: View open/close operations
  363. '---------------------------------------------
  364. Sub TestStep3 (app)
  365. WScript.Echo "test step 3: View operations"
  366. '- - - - - - - - - - - - - - - - - - - - - - -
  367. ' add the new view
  368. '- - - - - - - - - - - - - - - - - - - - - - -
  369. Set AppEvent_OnNewView_View = Nothing
  370. dim child
  371. set child = app.Document.ScopeNamespace.GetChild(app.Document.ScopeNamespace.GetRoot)
  372. '**BUGBUG** app.Document.Views.Add app.Document.ScopeNamespace.GetChild(child)
  373. AppEvent_OnNewView_IsExpected = True
  374. AppEvent_OnSelectionChange_IsExpected = True '**BUGBUG**
  375. AppEvent_OnViewChange_IsExpected = True '**BUGBUG**
  376. app.Document.Views.Add app.Document.ScopeNamespace.GetNext(child)
  377. AppEvent_OnViewChange_IsExpected = False
  378. AppEvent_OnSelectionChange_IsExpected = False
  379. AppEvent_OnNewView_IsExpected = False
  380. '- - - - - - - - - - - - - - - - - - - - - - -
  381. ' see if we've got an event
  382. '- - - - - - - - - - - - - - - - - - - - - - -
  383. if Not AppEvent_OnNewView_View is app.Document.Views(2) Then
  384. Err.Raise 100, "TestStep3", "Failed to catch NewView event"
  385. End If
  386. '- - - - - - - - - - - - - - - - - - - - - - -
  387. ' close the view
  388. '- - - - - - - - - - - - - - - - - - - - - - -
  389. Set AppEvent_OnViewClose_View = Nothing
  390. AppEvent_OnViewClose_IsExpected = True
  391. AppEvent_OnSelectionChange_IsExpected = True '**BUGBUG**
  392. AppEvent_OnNewView_View.Close
  393. AppEvent_OnSelectionChange_IsExpected = False
  394. AppEvent_OnViewClose_IsExpected = False
  395. if Not AppEvent_OnNewView_View is AppEvent_OnViewClose_View Then
  396. Err.Raise 100, "TestStep3", "Failed to catch CloseView event"
  397. End If
  398. Set AppEvent_OnViewClose_View = Nothing
  399. Set AppEvent_OnNewView_View = Nothing
  400. WScript.Echo "test step 3: complete"
  401. End Sub
  402. '---------------------------------------------
  403. ' test step final:
  404. '---------------------------------------------
  405. Sub TestStepFinal (app)
  406. WScript.Echo "test step final: Closing MMC"
  407. '- - - - - - - - - - - - - - - - - - - - - - -
  408. ' close the application
  409. '- - - - - - - - - - - - - - - - - - - - - - -
  410. Set AppEvent_OnQuit_Application = Nothing
  411. AppEvent_OnDocumentClose_IsExpected = True
  412. AppEvent_OnQuit_IsExpected = True
  413. AppEvent_OnSelectionChange_IsExpected = True '**BUGBUG**
  414. app.Quit
  415. AppEvent_OnSelectionChange_IsExpected = False
  416. AppEvent_OnQuit_IsExpected = False
  417. AppEvent_OnDocumentClose_IsExpected = False
  418. '- - - - - - - - - - - - - - - - - - - - - - -
  419. ' see if we've got a close event
  420. '- - - - - - - - - - - - - - - - - - - - - - -
  421. If Not AppEvent_OnQuit_Application Is app Then
  422. Err.Raise 100, "TestStepFinal", "Failed to catch application close event"
  423. End If
  424. Set AppEvent_OnQuit_Application = Nothing
  425. WScript.Echo "test step final: complete"
  426. End Sub
  427. '****************************************************************
  428. '* Main
  429. '****************************************************************
  430. Sub main
  431. WScript.Echo "Starting test pass for MMC events."
  432. AppEvent_OnQuit_IsExpected = False
  433. AppEvent_OnDocumentOpen_IsExpected = False
  434. AppEvent_OnDocumentClose_IsExpected = False
  435. AppEvent_OnSnapInAdded_IsExpected = False
  436. AppEvent_OnSnapInRemoved_IsExpected = False
  437. AppEvent_OnNewView_IsExpected = False
  438. AppEvent_OnViewClose_IsExpected = False
  439. AppEvent_OnViewChange_IsExpected = False
  440. AppEvent_OnSelectionChange_IsExpected = False
  441. AppEvent_OnCreateContextMenu_IsExpected = False
  442. AppEvent_OnContextMenuExecuted_IsExpected = False
  443. '- - - - - - - - - - - - - - - - - - - - - - -
  444. ' start mmc
  445. '- - - - - - - - - - - - - - - - - - - - - - -
  446. Dim mmc
  447. set mmc = wscript.CreateObject("MMC20.Application")
  448. '- - - - - - - - - - - - - - - - - - - - - - -
  449. ' connect objects to events
  450. '- - - - - - - - - - - - - - - - - - - - - - -
  451. wscript.ConnectObject mmc , "AppEvent_"
  452. '- - - - - - - - - - - - - - - - - - - - - - -
  453. ' persform testing...
  454. '- - - - - - - - - - - - - - - - - - - - - - -
  455. TestStep1 mmc
  456. If ErrorInEvent Then
  457. Err.Raise 100, "Test", "Failed due to error in event handler"
  458. End If
  459. TestStep2 mmc
  460. If ErrorInEvent Then
  461. Err.Raise 100, "Test", "Failed due to error in event handler"
  462. End If
  463. TestStep3 mmc
  464. If ErrorInEvent Then
  465. Err.Raise 100, "Test", "Failed due to error in event handler"
  466. End If
  467. '**commented to test exit on releasing all refs** TestStepFinal mmc
  468. If ErrorInEvent Then
  469. Err.Raise 100, "Test", "Failed due to error in event handler"
  470. End If
  471. WScript.Echo ""
  472. WScript.Echo "Test pass completed without errors"
  473. WScript.Echo ""
  474. '- - - - - - - - - - - - - - - - - - - - - - -
  475. ' take a nap
  476. '- - - - - - - - - - - - - - - - - - - - - - -
  477. wscript.sleep 500
  478. '- - - - - - - - - - - - - - - - - - - - - - -
  479. ' cleanup
  480. '- - - - - - - - - - - - - - - - - - - - - - -
  481. Set mmc = Nothing
  482. Set AppEvent_OnQuit_Application = Nothing
  483. Set AppEvent_OnDocumentOpen_Document = Nothing
  484. Set AppEvent_OnDocumentOpen_bNew = Nothing
  485. Set AppEvent_OnDocumentClose_Document = Nothing
  486. Set AppEvent_OnSnapInAdded_Document = Nothing
  487. Set AppEvent_OnSnapInAdded_SnapIn = Nothing
  488. Set AppEvent_OnSnapInRemoved_Document = Nothing
  489. Set AppEvent_OnSnapInRemoved_SnapIn = Nothing
  490. Set AppEvent_OnNewView_View = Nothing
  491. Set AppEvent_OnViewClose_View = Nothing
  492. Set AppEvent_OnViewChange_View = Nothing
  493. Set AppEvent_OnViewChange_NewOwnerNode = Nothing
  494. Set AppEvent_OnSelectionChange_View = Nothing
  495. Set AppEvent_OnSelectionChange_NewNodes = Nothing
  496. Set AppEvent_OnCreateContextMenu_View = Nothing
  497. Set AppEvent_OnCreateContextMenu_Nodes = Nothing
  498. Set AppEvent_OnCreateContextMenu_Menu = Nothing
  499. End Sub
  500. '---------------------------------------------
  501. ' startup: call main
  502. '---------------------------------------------
  503. main