Commit 9a89db98 authored by Anton Romanov's avatar Anton Romanov Committed by Alexandre Julliard

wmp: Add IWMPMedia stub.

parent e36b765b
......@@ -308,6 +308,7 @@ static ULONG WINAPI OleObject_Release(IOleObject *iface)
if(!ref) {
release_client_site(This);
ConnectionPointContainer_Destroy(This);
destroy_player(This);
heap_free(This);
}
......
......@@ -2,3 +2,6 @@ TESTDLL = wmp.dll
IMPORTS = ole32 oleaut32 user32 gdi32
C_SRCS = oleobj.c
RC_SRCS = \
rsrc.rc
......@@ -18,12 +18,16 @@
#define WIN32_LEAN_AND_MEAN
#define COBJMACROS
#include <stdarg.h>
#include <initguid.h>
#include <windef.h>
#include <winbase.h>
#include <windows.h>
#include <wmp.h>
#include <olectl.h>
#include "wine/test.h"
#include "wine/heap.h"
#define DEFINE_EXPECT(func) \
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
......@@ -49,6 +53,12 @@
expect_ ## func = called_ ## func = FALSE; \
}while(0)
#define CHECK_CALLED_OR_BROKEN(func) \
do { \
ok(called_ ## func || broken(1), "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE; \
}while(0)
DEFINE_EXPECT(GetContainer);
DEFINE_EXPECT(GetExtendedControl);
DEFINE_EXPECT(GetWindow);
......@@ -60,6 +70,32 @@ DEFINE_EXPECT(GetWindowContext);
DEFINE_EXPECT(ShowObject);
DEFINE_EXPECT(OnShowWindow_FALSE);
static const WCHAR mp4file[] = {'a','v','.','m','p','4',0};
static inline WCHAR *load_resource(const WCHAR *name)
{
static WCHAR pathW[MAX_PATH];
DWORD written;
HANDLE file;
HRSRC res;
void *ptr;
GetTempPathW(sizeof(pathW)/sizeof(WCHAR), pathW);
lstrcatW(pathW, name);
file = CreateFileW(pathW, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %d\n", wine_dbgstr_w(pathW),
GetLastError());
res = FindResourceW(NULL, name, (LPCWSTR)RT_RCDATA);
ok( res != 0, "couldn't find resource\n" );
ptr = LockResource( LoadResource( GetModuleHandleA(NULL), res ));
WriteFile( file, ptr, SizeofResource( GetModuleHandleA(NULL), res ), &written, NULL );
ok( written == SizeofResource( GetModuleHandleA(NULL), res ), "couldn't write resource\n" );
CloseHandle( file );
return pathW;
}
static HWND container_hwnd;
static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
......@@ -859,9 +895,12 @@ static void test_wmp_ifaces(IOleObject *oleobj)
IWMPSettings *settings, *settings_qi;
IWMPPlayer4 *player4;
IWMPPlayer *player;
IWMPMedia *media;
IWMPControls *controls;
VARIANT_BOOL vbool;
HRESULT hres;
BSTR filename;
BSTR url;
hres = IOleObject_QueryInterface(oleobj, &IID_IWMPPlayer4, (void**)&player4);
ok(hres == S_OK, "Could not get IWMPPlayer4 iface: %08x\n", hres);
......@@ -878,6 +917,52 @@ static void test_wmp_ifaces(IOleObject *oleobj)
IWMPControls_Release(controls);
media = NULL;
hres = IWMPPlayer4_QueryInterface(player4, &IID_IWMPMedia, (void**)&media);
ok(hres == E_NOINTERFACE, "get_currentMedia SUCCEEDED: %08x\n", hres);
ok(media == NULL, "media != NULL\n");
/* Test media put/get */
media = NULL;
hres = IWMPPlayer4_get_currentMedia(player4, &media);
ok(hres == S_FALSE, "get_currentMedia SUCCEEDED\n");
ok(media == NULL, "media != NULL\n");
filename = SysAllocString(load_resource(mp4file));
SET_EXPECT(GetContainer);
SET_EXPECT(Invoke_USERMODE);
hres = IWMPPlayer4_put_URL(player4, filename);
ok(hres == S_OK, "IWMPPlayer4_put_URL failed: %08x\n", hres);
todo_wine CHECK_CALLED_OR_BROKEN(GetContainer);
todo_wine CHECK_CALLED(Invoke_USERMODE);
url = NULL;
SET_EXPECT(Invoke_USERMODE);
hres = IWMPPlayer4_get_URL(player4, &url);
todo_wine ok(hres == S_OK, "IWMPPlayer4_get_URL failed: %08x\n", hres);
todo_wine ok(0 == lstrcmpW(url, filename), "%s != %s", wine_dbgstr_w(url), wine_dbgstr_w(filename));
todo_wine CHECK_CALLED(Invoke_USERMODE);
SysFreeString(url);
hres = IWMPPlayer4_get_currentMedia(player4, &media);
ok(hres == S_OK, "get_currentMedia failed: %08x\n", hres);
ok(media != NULL, "media = (%p)\n", media);
SET_EXPECT(GetContainer);
hres = IWMPPlayer4_put_currentMedia(player4, media);
ok(hres == S_OK, "put_currentMedia failed: %08x\n", hres);
todo_wine CHECK_CALLED_OR_BROKEN(GetContainer);
IWMPMedia_Release(media);
hres = IWMPPlayer4_get_currentMedia(player4, &media);
ok(hres == S_OK, "get_currentMedia failed: %08x\n", hres);
ok(media != NULL, "media = (%p)\n", media);
IWMPMedia_Release(media);
settings = NULL;
hres = IWMPPlayer4_get_settings(player4, &settings);
ok(hres == S_OK, "get_settings failed: %08x\n", hres);
......@@ -934,6 +1019,7 @@ static void test_wmp_ifaces(IOleObject *oleobj)
IWMPSettings_Release(settings);
IWMPPlayer_Release(player);
SysFreeString(filename);
}
#define test_rect_size(a,b,c) _test_rect_size(__LINE__,a,b,c)
......
/*
* Resource file for wmp tests.
*
* 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
*/
#include "windef.h"
/* @makedep: av.mp4 */
av.mp4 RCDATA "av.mp4"
......@@ -20,6 +20,7 @@
#include "windows.h"
#include "wine/heap.h"
#include "wine/unicode.h"
#include "ole2.h"
#include "wmp.h"
......@@ -34,6 +35,14 @@ typedef struct {
IID iid;
} ConnectionPoint;
typedef struct {
IWMPMedia IWMPMedia_iface;
LONG ref;
WCHAR *url;
} WMPMedia;
struct WindowsMediaPlayer {
IOleObject IOleObject_iface;
IProvideClassInfo2 IProvideClassInfo2_iface;
......@@ -58,9 +67,13 @@ struct WindowsMediaPlayer {
VARIANT_BOOL enable_error_dialogs;
ConnectionPoint *wmpocx;
IWMPMedia *wmpmedia;
};
void init_player(WindowsMediaPlayer*) DECLSPEC_HIDDEN;
void destroy_player(WindowsMediaPlayer*) DECLSPEC_HIDDEN;
IWMPMedia* create_media_from_url(BSTR url);
void ConnectionPointContainer_Init(WindowsMediaPlayer *wmp) DECLSPEC_HIDDEN;
void ConnectionPointContainer_Destroy(WindowsMediaPlayer *wmp) DECLSPEC_HIDDEN;
......@@ -69,3 +82,19 @@ HRESULT WINAPI WMPFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**)
void unregister_wmp_class(void) DECLSPEC_HIDDEN;
extern HINSTANCE wmp_instance DECLSPEC_HIDDEN;
static inline WCHAR *heap_strdupW(const WCHAR *str)
{
WCHAR *ret;
if(str) {
size_t size = strlenW(str)+1;
ret = heap_alloc(size*sizeof(WCHAR));
if(ret)
memcpy(ret, str, size*sizeof(WCHAR));
}else {
ret = NULL;
}
return ret;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment