Sweden-Number/dlls/wmvcore/tests/wmvcore.c

247 lines
8.7 KiB
C
Raw Normal View History

/*
* Copyright 2017 Alistair Leslie-Hughes
* Copyright 2019 Vijay Kiran Kamuju
*
* 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
#define WIN32_LEAN_AND_MEAN
#include "initguid.h"
#include "wmsdk.h"
#include "wine/test.h"
HRESULT WINAPI WMCreateWriterPriv(IWMWriter **writer);
#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c)
static HRESULT check_interface_(unsigned int line, void *iface, REFIID riid, BOOL supported)
{
HRESULT hr, expected_hr;
IUnknown *unknown = iface, *out;
expected_hr = supported ? S_OK : E_NOINTERFACE;
hr = IUnknown_QueryInterface(unknown, riid, (void **)&out);
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr);
if (SUCCEEDED(hr))
IUnknown_Release(out);
return hr;
}
static void test_wmwriter_interfaces(void)
{
HRESULT hr;
IWMWriter *writer;
hr = WMCreateWriter( NULL, &writer );
ok(hr == S_OK, "WMCreateWriter failed 0x%08x\n", hr);
if(FAILED(hr))
{
win_skip("Failed to create IWMWriter\n");
return;
}
check_interface(writer, &IID_IWMWriterSink, FALSE);
check_interface(writer, &IID_IWMWriter, TRUE);
check_interface(writer, &IID_IWMWriterAdvanced, TRUE);
check_interface(writer, &IID_IWMWriterAdvanced2, TRUE);
check_interface(writer, &IID_IWMWriterAdvanced3, TRUE);
todo_wine check_interface(writer, &IID_IWMWriterPreprocess, TRUE);
todo_wine check_interface(writer, &IID_IWMHeaderInfo, TRUE);
todo_wine check_interface(writer, &IID_IWMHeaderInfo2, TRUE);
todo_wine check_interface(writer, &IID_IWMHeaderInfo3, TRUE);
IWMWriter_Release(writer);
}
static void test_wmreader_interfaces(void)
{
HRESULT hr;
IWMReader *reader;
hr = WMCreateReader( NULL, 0, &reader );
ok(hr == S_OK, "WMCreateReader failed 0x%08x\n", hr);
if(FAILED(hr))
{
win_skip("Failed to create IWMReader\n");
return;
}
check_interface(reader, &IID_IWMDRMReader, FALSE);
check_interface(reader, &IID_IWMDRMReader2, FALSE);
check_interface(reader, &IID_IWMDRMReader3, FALSE);
check_interface(reader, &IID_IWMSyncReader, FALSE);
check_interface(reader, &IID_IWMSyncReader2, FALSE);
check_interface(reader, &IID_IWMReader, TRUE);
check_interface(reader, &IID_IWMReaderAdvanced, TRUE);
check_interface(reader, &IID_IWMReaderAdvanced2, TRUE);
check_interface(reader, &IID_IWMReaderAdvanced3, TRUE);
check_interface(reader, &IID_IWMReaderAdvanced4, TRUE);
check_interface(reader, &IID_IWMReaderAdvanced5, TRUE);
check_interface(reader, &IID_IWMReaderAdvanced6, TRUE);
check_interface(reader, &IID_IWMHeaderInfo, TRUE);
check_interface(reader, &IID_IWMHeaderInfo2, TRUE);
check_interface(reader, &IID_IWMHeaderInfo3, TRUE);
check_interface(reader, &IID_IWMProfile, TRUE);
check_interface(reader, &IID_IWMProfile2, TRUE);
check_interface(reader, &IID_IWMProfile3, TRUE);
check_interface(reader, &IID_IWMPacketSize, TRUE);
check_interface(reader, &IID_IWMPacketSize2, TRUE);
check_interface(reader, &IID_IWMReaderAccelerator, TRUE);
check_interface(reader, &IID_IWMReaderTimecode, TRUE);
check_interface(reader, &IID_IWMReaderNetworkConfig, TRUE);
check_interface(reader, &IID_IWMReaderNetworkConfig2, TRUE);
check_interface(reader, &IID_IWMReaderStreamClock, TRUE);
check_interface(reader, &IID_IWMReaderTypeNegotiation, TRUE);
check_interface(reader, &IID_IWMReaderPlaylistBurn, TRUE);
check_interface(reader, &IID_IWMLanguageList, TRUE);
check_interface(reader, &IID_IReferenceClock, TRUE);
IWMReader_Release(reader);
}
static void test_wmsyncreader_interfaces(void)
{
HRESULT hr;
IWMSyncReader *reader;
hr = WMCreateSyncReader( NULL, 0, &reader );
ok(hr == S_OK, "WMCreateSyncReader failed 0x%08x\n", hr);
if(FAILED(hr))
{
win_skip("Failed to create IWMSyncReader\n");
return;
}
check_interface(reader, &IID_IWMDRMReader, FALSE);
check_interface(reader, &IID_IWMDRMReader2, FALSE);
check_interface(reader, &IID_IWMDRMReader3, FALSE);
check_interface(reader, &IID_IWMReader, FALSE);
check_interface(reader, &IID_IWMReaderAccelerator, FALSE);
check_interface(reader, &IID_IWMReaderAdvanced, FALSE);
check_interface(reader, &IID_IWMReaderAdvanced2, FALSE);
check_interface(reader, &IID_IWMReaderAdvanced3, FALSE);
check_interface(reader, &IID_IWMReaderAdvanced4, FALSE);
check_interface(reader, &IID_IWMReaderAdvanced5, FALSE);
check_interface(reader, &IID_IWMReaderAdvanced6, FALSE);
check_interface(reader, &IID_IWMReaderNetworkConfig, FALSE);
check_interface(reader, &IID_IWMReaderNetworkConfig2, FALSE);
check_interface(reader, &IID_IWMReaderStreamClock, FALSE);
check_interface(reader, &IID_IWMReaderTypeNegotiation, FALSE);
check_interface(reader, &IID_IReferenceClock, FALSE);
check_interface(reader, &IID_IWMSyncReader, TRUE);
check_interface(reader, &IID_IWMSyncReader2, TRUE);
todo_wine check_interface(reader, &IID_IWMHeaderInfo, TRUE);
todo_wine check_interface(reader, &IID_IWMHeaderInfo2, TRUE);
todo_wine check_interface(reader, &IID_IWMHeaderInfo3, TRUE);
check_interface(reader, &IID_IWMProfile, TRUE);
check_interface(reader, &IID_IWMProfile2, TRUE);
check_interface(reader, &IID_IWMProfile3, TRUE);
todo_wine check_interface(reader, &IID_IWMPacketSize, TRUE);
todo_wine check_interface(reader, &IID_IWMPacketSize2, TRUE);
todo_wine check_interface(reader, &IID_IWMReaderTimecode, TRUE);
todo_wine check_interface(reader, &IID_IWMReaderPlaylistBurn, TRUE);
todo_wine check_interface(reader, &IID_IWMLanguageList, TRUE);
IWMSyncReader_Release(reader);
}
static void test_profile_manager_interfaces(void)
{
HRESULT hr;
IWMProfileManager *profile;
hr = WMCreateProfileManager(&profile);
ok(hr == S_OK, "WMCreateProfileManager failed 0x%08x\n", hr);
if(FAILED(hr))
{
win_skip("Failed to create IWMProfileManager\n");
return;
}
IWMProfileManager_Release(profile);
}
static void test_WMCreateWriterPriv(void)
{
IWMWriter *writer, *writer2;
HRESULT hr;
hr = WMCreateWriterPriv(&writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IWMWriter_QueryInterface(writer, &IID_IWMWriter, (void**)&writer2);
ok(hr == S_OK, "got 0x%08x\n", hr);
IWMWriter_Release(writer);
IWMWriter_Release(writer2);
}
static void test_urlextension(void)
{
HRESULT hr;
hr = WMCheckURLExtension(NULL);
ok(hr == E_INVALIDARG, "WMCheckURLExtension failed 0x%08x\n", hr);
hr = WMCheckURLExtension(L"test.mkv");
ok(hr == NS_E_INVALID_NAME, "WMCheckURLExtension failed 0x%08x\n", hr);
hr = WMCheckURLExtension(L"test.mp3");
todo_wine ok(hr == S_OK, "WMCheckURLExtension failed 0x%08x\n", hr);
hr = WMCheckURLExtension(L"abcd://test/test.wmv");
todo_wine ok(hr == S_OK, "WMCheckURLExtension failed 0x%08x\n", hr);
hr = WMCheckURLExtension(L"http://test/t.asf?alt=t.mkv");
todo_wine ok(hr == S_OK, "WMCheckURLExtension failed 0x%08x\n", hr);
}
static void test_iscontentprotected(void)
{
HRESULT hr;
BOOL drm;
hr = WMIsContentProtected(NULL, NULL);
ok(hr == E_INVALIDARG, "WMIsContentProtected failed 0x%08x\n", hr);
hr = WMIsContentProtected(NULL, &drm);
ok(hr == E_INVALIDARG, "WMIsContentProtected failed 0x%08x\n", hr);
hr = WMIsContentProtected(L"test.mp3", NULL);
ok(hr == E_INVALIDARG, "WMIsContentProtected failed 0x%08x\n", hr);
hr = WMIsContentProtected(L"test.mp3", &drm);
ok(hr == S_FALSE, "WMIsContentProtected failed 0x%08x\n", hr);
ok(drm == FALSE, "got %0dx\n", drm);
}
START_TEST(wmvcore)
{
HRESULT hr;
hr = CoInitialize(0);
ok(hr == S_OK, "failed to init com\n");
if(hr != S_OK)
return;
test_wmreader_interfaces();
test_wmsyncreader_interfaces();
test_wmwriter_interfaces();
test_profile_manager_interfaces();
test_WMCreateWriterPriv();
test_urlextension();
test_iscontentprotected();
CoUninitialize();
}