mfplay: Keep user callback reference.
[wine.git] / dlls / mfplay / tests / mfplay.c
blobef8aaddc76f3e156e18282b8f473e7c5c377d42d
1 /*
2 * Copyright 2021 Nikolay Sivov for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "mfplay.h"
27 #include "wine/test.h"
29 static HRESULT WINAPI test_callback_QueryInterface(IMFPMediaPlayerCallback *iface, REFIID riid, void **obj)
31 if (IsEqualIID(riid, &IID_IMFPMediaPlayerCallback) ||
32 IsEqualIID(riid, &IID_IUnknown))
34 *obj = iface;
35 IMFPMediaPlayerCallback_AddRef(iface);
36 return S_OK;
39 *obj = NULL;
40 return E_NOINTERFACE;
43 static ULONG WINAPI test_callback_AddRef(IMFPMediaPlayerCallback *iface)
45 return 2;
48 static ULONG WINAPI test_callback_Release(IMFPMediaPlayerCallback *iface)
50 return 1;
53 static void WINAPI test_callback_OnMediaPlayerEvent(IMFPMediaPlayerCallback *iface, MFP_EVENT_HEADER *event_header)
57 static const IMFPMediaPlayerCallbackVtbl test_callback_vtbl =
59 test_callback_QueryInterface,
60 test_callback_AddRef,
61 test_callback_Release,
62 test_callback_OnMediaPlayerEvent,
65 static void test_create_player(void)
67 IMFPMediaPlayerCallback callback = { &test_callback_vtbl };
68 IMFPMediaPlayer *player;
69 HRESULT hr;
71 hr = MFPCreateMediaPlayer(NULL, FALSE, 0, NULL, NULL, &player);
72 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
73 IMFPMediaPlayer_Release(player);
75 hr = MFPCreateMediaPlayer(NULL, FALSE, 0, &callback, NULL, &player);
76 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
77 IMFPMediaPlayer_Release(player);
80 START_TEST(mfplay)
82 test_create_player();