Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make test IUnknown conforming #112566

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 21 additions & 23 deletions src/tests/Interop/COM/NativeClients/MiscTypes/MiscTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,23 @@ struct VariantMarshalTest
}
};

class InterfaceImpl :
public UnknownImpl,
public IInterface2
{
public: // IInterface1
public: // IInterface2
public: // IUnknown
STDMETHOD(QueryInterface)(
/* [in] */ REFIID riid,
/* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject)
{
return DoQueryInterface(riid, ppvObject, static_cast<IInterface1 *>(this), static_cast<IInterface2 *>(this));
}

DEFINE_REF_COUNTING();
};

void ValidationTests()
{
::printf(__FUNCTION__ "() through CoCreateInstance...\n");
Expand Down Expand Up @@ -334,30 +351,11 @@ void ValidationTests()

::printf("-- Interfaces...\n");
{
struct InterfaceImpl : IInterface2
{
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject) override
{
if (riid == __uuidof(IInterface1) || riid == __uuidof(IInterface2))
{
*ppvObject = static_cast<IInterface2*>(this);
}
else if (riid == __uuidof(IUnknown))
{
*ppvObject = static_cast<IUnknown*>(this);
}
else
{
*ppvObject = nullptr;
return E_NOINTERFACE;
}
return S_OK;
}
STDMETHOD_(ULONG, AddRef)() override { return 1; }
STDMETHOD_(ULONG, Release)() override { return 1; }
} iface{};
ComSmartPtr<InterfaceImpl> iface;
iface.Attach(new InterfaceImpl());

ComSmartPtr<IInterface2> result;
HRESULT hr = miscTypesTesting->Marshal_Interface(&iface, &result);
HRESULT hr = miscTypesTesting->Marshal_Interface(iface, &result);
THROW_IF_FAILED(hr);
}
}
Expand Down