2020-07-17 21:50:19 +02:00
|
|
|
/*
|
|
|
|
* Navigator filter unit tests
|
|
|
|
*
|
|
|
|
* Copyright 2020 Gijs Vermeulen
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#include "dshow.h"
|
|
|
|
#include "wine/strmbase.h"
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
static IBaseFilter *create_navigator(void)
|
|
|
|
{
|
|
|
|
IBaseFilter *filter = NULL;
|
|
|
|
HRESULT hr = CoCreateInstance(&CLSID_DVDNavigator, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (void **)&filter);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-07-17 21:50:19 +02:00
|
|
|
return filter;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG get_refcount(void *iface)
|
|
|
|
{
|
|
|
|
IUnknown *unknown = iface;
|
|
|
|
IUnknown_AddRef(unknown);
|
|
|
|
return IUnknown_Release(unknown);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c)
|
|
|
|
static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported)
|
|
|
|
{
|
|
|
|
IUnknown *iface = iface_ptr;
|
|
|
|
HRESULT hr, expected_hr;
|
|
|
|
IUnknown *unk;
|
|
|
|
|
|
|
|
expected_hr = supported ? S_OK : E_NOINTERFACE;
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(iface, iid, (void **)&unk);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#lx, expected %#lx.\n", hr, expected_hr);
|
2020-07-17 21:50:19 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_interfaces(void)
|
|
|
|
{
|
|
|
|
IBaseFilter *filter = create_navigator();
|
|
|
|
|
|
|
|
check_interface(filter, &IID_IBaseFilter, TRUE);
|
|
|
|
todo_wine check_interface(filter, &IID_IDvdControl, TRUE);
|
2020-07-17 21:50:20 +02:00
|
|
|
check_interface(filter, &IID_IDvdControl2, TRUE);
|
2020-07-17 21:50:19 +02:00
|
|
|
todo_wine check_interface(filter, &IID_IDvdInfo, TRUE);
|
2020-07-28 10:29:58 +02:00
|
|
|
check_interface(filter, &IID_IDvdInfo2, TRUE);
|
2020-07-17 21:50:19 +02:00
|
|
|
check_interface(filter, &IID_IMediaFilter, TRUE);
|
|
|
|
check_interface(filter, &IID_IPersist, TRUE);
|
|
|
|
todo_wine check_interface(filter, &IID_ISpecifyPropertyPages, TRUE);
|
|
|
|
check_interface(filter, &IID_IUnknown, TRUE);
|
|
|
|
|
|
|
|
check_interface(filter, &IID_IAMFilterMiscFlags, FALSE);
|
|
|
|
check_interface(filter, &IID_IBasicAudio, FALSE);
|
|
|
|
check_interface(filter, &IID_IBasicVideo, FALSE);
|
|
|
|
check_interface(filter, &IID_IFileSourceFilter, FALSE);
|
|
|
|
check_interface(filter, &IID_IKsPropertySet, FALSE);
|
|
|
|
check_interface(filter, &IID_IMediaPosition, FALSE);
|
|
|
|
check_interface(filter, &IID_IMediaSeeking, FALSE);
|
|
|
|
check_interface(filter, &IID_IPersistPropertyBag, FALSE);
|
|
|
|
check_interface(filter, &IID_IPersistStream, FALSE);
|
|
|
|
check_interface(filter, &IID_IPin, FALSE);
|
|
|
|
check_interface(filter, &IID_IQualityControl, FALSE);
|
|
|
|
check_interface(filter, &IID_IQualProp, FALSE);
|
|
|
|
check_interface(filter, &IID_IReferenceClock, FALSE);
|
|
|
|
check_interface(filter, &IID_IVideoWindow, FALSE);
|
|
|
|
|
|
|
|
IBaseFilter_Release(filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GUID test_iid = {0x33333333};
|
|
|
|
static LONG outer_ref = 1;
|
|
|
|
|
|
|
|
static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(iid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(iid, &IID_IBaseFilter)
|
|
|
|
|| IsEqualGUID(iid, &test_iid))
|
|
|
|
{
|
|
|
|
*out = (IUnknown *)0xdeadbeef;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
ok(0, "unexpected call %s\n", wine_dbgstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI outer_AddRef(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return InterlockedIncrement(&outer_ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI outer_Release(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return InterlockedDecrement(&outer_ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IUnknownVtbl outer_vtbl =
|
|
|
|
{
|
|
|
|
outer_QueryInterface,
|
|
|
|
outer_AddRef,
|
|
|
|
outer_Release,
|
|
|
|
};
|
|
|
|
|
|
|
|
static IUnknown test_outer = {&outer_vtbl};
|
|
|
|
|
|
|
|
static void test_aggregation(void)
|
|
|
|
{
|
|
|
|
IBaseFilter *filter, *filter2;
|
|
|
|
IUnknown *unk, *unk2;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
filter = (IBaseFilter *)0xdeadbeef;
|
|
|
|
hr = CoCreateInstance(&CLSID_DVDNavigator, &test_outer, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IBaseFilter, (void **)&filter);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
|
2020-07-17 21:50:19 +02:00
|
|
|
ok(!filter, "Got interface %p.\n", filter);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_DVDNavigator, &test_outer, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IUnknown, (void **)&unk);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
|
2020-07-17 21:50:19 +02:00
|
|
|
ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
|
|
|
|
ref = get_refcount(unk);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
|
2020-07-17 21:50:19 +02:00
|
|
|
|
|
|
|
ref = IUnknown_AddRef(unk);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(ref == 2, "Got unexpected refcount %ld.\n", ref);
|
|
|
|
ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
|
2020-07-17 21:50:19 +02:00
|
|
|
|
|
|
|
ref = IUnknown_Release(unk);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
|
|
|
|
ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
|
2020-07-17 21:50:19 +02:00
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void **)&unk2);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-07-17 21:50:19 +02:00
|
|
|
ok(unk2 == unk, "Got unexpected IUnknown %p.\n", unk2);
|
|
|
|
IUnknown_Release(unk2);
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(unk, &IID_IBaseFilter, (void **)&filter);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-07-17 21:50:19 +02:00
|
|
|
|
|
|
|
hr = IBaseFilter_QueryInterface(filter, &IID_IUnknown, (void **)&unk2);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-07-17 21:50:19 +02:00
|
|
|
ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
|
|
|
|
|
|
|
|
hr = IBaseFilter_QueryInterface(filter, &IID_IBaseFilter, (void **)&filter2);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-07-17 21:50:19 +02:00
|
|
|
ok(filter2 == (IBaseFilter *)0xdeadbeef, "Got unexpected IBaseFilter %p.\n", filter2);
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(unk, &test_iid, (void **)&unk2);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
|
2020-07-17 21:50:19 +02:00
|
|
|
ok(!unk2, "Got unexpected IUnknown %p.\n", unk2);
|
|
|
|
|
|
|
|
hr = IBaseFilter_QueryInterface(filter, &test_iid, (void **)&unk2);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-07-17 21:50:19 +02:00
|
|
|
ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
|
|
|
|
|
|
|
|
IBaseFilter_Release(filter);
|
|
|
|
ref = IUnknown_Release(unk);
|
2022-03-03 08:22:33 +01:00
|
|
|
ok(!ref, "Got unexpected refcount %ld.\n", ref);
|
|
|
|
ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
|
2020-07-17 21:50:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(navigator)
|
|
|
|
{
|
|
|
|
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
|
|
|
|
|
|
|
test_interfaces();
|
|
|
|
test_aggregation();
|
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|