Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
junkmd committed Jun 29, 2024
1 parent d0826aa commit b3441e1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions comtypes/test/test_midl_safearray_create.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding: utf-8

from ctypes import c_int, pointer, POINTER
import sys
import unittest

import comtypes
Expand All @@ -12,6 +13,12 @@
GetModule("UIAutomationCore.dll")
from comtypes.gen.UIAutomationClient import CUIAutomation, IUIAutomation

GetModule(("{C866CA3A-32F7-11D2-9602-00C04F8EE628}",))
from comtypes.gen.SpeechLib import SpVoice, ISpeechVoice

GetModule("scrrun.dll")
from comtypes.gen.Scripting import Dictionary, IDictionary

ComtypesCppTestSrvLib_GUID = "{07D2AEE5-1DF8-4D2C-953A-554ADFD25F99}"

try:
Expand Down Expand Up @@ -58,6 +65,32 @@ def test_idisp(self):
(unpacked,) = sa.unpack()
self.assertIsInstance(unpacked, POINTER(IDispSafearrayParamTest))

def test_sapi(self):
extra = pointer(ISpeechVoice._iid_)
ispvoice = CreateObject(SpVoice, interface=ISpeechVoice)
sa_type = comtypes.safearray._midlSAFEARRAY(POINTER(ISpeechVoice))
for ptn, sa in [
("with extra", sa_type.create([ispvoice], extra=extra)),
("without extra", sa_type.create([ispvoice])),
]:
with self.subTest(ptn=ptn):
(unpacked,) = sa.unpack()
self.assertIsInstance(unpacked, POINTER(ISpeechVoice))

def test_idic(self):
extra = pointer(IDictionary._iid_)
idic = CreateObject(Dictionary, interface=IDictionary)
idic["foo"] = "bar"
sa_type = comtypes.safearray._midlSAFEARRAY(POINTER(IDictionary))
for ptn, sa in [
("with extra", sa_type.create([idic], extra=extra)),
("without extra", sa_type.create([idic])),
]:
with self.subTest(ptn=ptn):
(unpacked,) = sa.unpack()
self.assertIsInstance(unpacked, POINTER(IDictionary))
self.assertEqual(unpacked["foo"], "bar")

@unittest.skipIf(IMPORT_FAILED, "This depends on the out of process COM-server.")
def test_record(self):
extra = comtypes.typeinfo.GetRecordInfoFromGuids(
Expand Down

0 comments on commit b3441e1

Please sign in to comment.