push 87b6981010d7405c33b14cddcceec21b47729eba
[wine/hacks.git] / dlls / mmdevapi / tests / propstore.c
blob37126220caebeccb4633c0ca3fd553673b58ab71
1 /*
2 * Copyright 2010 Maarten Lankhorst 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 #define NONAMELESSUNION
20 #include "wine/test.h"
22 #define CINTERFACE
23 #define COBJMACROS
25 #ifdef STANDALONE
26 #include "initguid.h"
27 #endif
29 #include "unknwn.h"
30 #include "uuids.h"
31 #include "mmdeviceapi.h"
33 static void test_propertystore(IPropertyStore *store)
35 HRESULT hr;
36 PROPVARIANT pv = { 0 };
37 char temp[40];
39 hr = IPropertyStore_GetValue(store, &PKEY_AudioEndpoint_GUID, &pv);
40 ok(hr == S_OK, "Failed with %08x\n", hr);
41 if (hr == S_OK)
43 WideCharToMultiByte(CP_ACP, 0, pv.u.pwszVal, -1, temp, sizeof(temp)-1, NULL, NULL);
44 temp[sizeof(temp)-1] = 0;
45 trace("guid: %s\n", temp);
46 CoTaskMemFree(pv.u.pwszVal);
50 START_TEST(propstore)
52 HRESULT hr;
53 IMMDeviceEnumerator *mme = NULL;
54 IMMDevice *dev = NULL;
55 IPropertyStore *store;
57 CoInitializeEx(NULL, COINIT_MULTITHREADED);
58 hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&mme);
59 if (FAILED(hr))
61 skip("mmdevapi not available: 0x%08x\n", hr);
62 goto cleanup;
65 hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(mme, eRender, eMultimedia, &dev);
66 ok(hr == S_OK || hr == E_NOTFOUND, "GetDefaultAudioEndpoint failed: 0x%08x\n", hr);
67 if (hr != S_OK)
69 if (hr == E_NOTFOUND)
70 skip("No sound card available\n");
71 else
72 skip("GetDefaultAudioEndpoint returns 0x%08x\n", hr);
73 goto cleanup;
75 store = NULL;
76 hr = IMMDevice_OpenPropertyStore(dev, 3, &store);
77 todo_wine ok(hr == E_INVALIDARG, "Wrong hr returned: %08x\n", hr);
78 if (hr != S_OK)
79 /* It seems on windows returning with E_INVALIDARG doesn't
80 * set store to NULL, so just don't set store to non-null
81 * before calling this function
83 ok(!store, "Store set to non-NULL on failure: %p/%08x\n", store, hr);
84 else if (store)
85 IPropertyStore_Release(store);
86 hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, NULL);
87 todo_wine ok(hr == E_POINTER, "Wrong hr returned: %08x\n", hr);
89 store = NULL;
90 hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, &store);
91 todo_wine ok(hr == S_OK, "Opening valid store returned %08x\n", hr);
92 if (store)
94 test_propertystore(store);
95 IPropertyStore_Release(store);
97 IMMDevice_Release(dev);
98 cleanup:
99 if (mme)
100 IUnknown_Release(mme);
101 CoUninitialize();