wined3d: Replace wined3d_surface_update_desc() with wined3d_texture_update_desc().
[wine.git] / dlls / mmdevapi / tests / propstore.c
blobbcb5044ab0e9218041909c1ea6f1c0f864be6455
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 COBJMACROS
24 #ifdef STANDALONE
25 #include "initguid.h"
26 #endif
28 #include "unknwn.h"
29 #include "uuids.h"
30 #include "mmdeviceapi.h"
31 #include "devpkey.h"
33 static void test_propertystore(IPropertyStore *store)
35 HRESULT hr;
36 PROPVARIANT pv;
37 char temp[128];
38 temp[sizeof(temp)-1] = 0;
40 pv.vt = VT_EMPTY;
41 hr = IPropertyStore_GetValue(store, &PKEY_AudioEndpoint_GUID, &pv);
42 ok(hr == S_OK, "Failed with %08x\n", hr);
43 ok(pv.vt == VT_LPWSTR, "Value should be %i, is %i\n", VT_LPWSTR, pv.vt);
44 if (hr == S_OK && pv.vt == VT_LPWSTR)
46 WideCharToMultiByte(CP_ACP, 0, pv.u.pwszVal, -1, temp, sizeof(temp)-1, NULL, NULL);
47 trace("guid: %s\n", temp);
48 CoTaskMemFree(pv.u.pwszVal);
51 pv.vt = VT_EMPTY;
52 hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_FriendlyName, &pv);
53 ok(hr == S_OK, "Failed with %08x\n", hr);
54 ok(pv.vt == VT_EMPTY, "Key should not be found\n");
56 pv.vt = VT_EMPTY;
57 hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_Enabled, &pv);
58 ok(hr == S_OK, "Failed with %08x\n", hr);
59 ok(pv.vt == VT_EMPTY, "Key should not be found\n");
61 pv.vt = VT_EMPTY;
62 hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_ClassGuid, &pv);
63 ok(hr == S_OK, "Failed with %08x\n", hr);
64 ok(pv.vt == VT_EMPTY, "Key should not be found\n");
67 static void test_deviceinterface(IPropertyStore *store)
69 HRESULT hr;
70 PROPVARIANT pv;
72 static const PROPERTYKEY deviceinterface_key = {
73 {0x233164c8, 0x1b2c, 0x4c7d, {0xbc, 0x68, 0xb6, 0x71, 0x68, 0x7a, 0x25, 0x67}}, 1
76 pv.vt = VT_EMPTY;
77 hr = IPropertyStore_GetValue(store, &deviceinterface_key, &pv);
78 ok(hr == S_OK, "GetValue failed: %08x\n", hr);
79 ok(pv.vt == VT_LPWSTR, "Got wrong variant type: 0x%x\n", pv.vt);
80 trace("device interface: %s\n", wine_dbgstr_w(pv.u.pwszVal));
81 CoTaskMemFree(pv.u.pwszVal);
84 static void test_getat(IPropertyStore *store)
86 HRESULT hr;
87 DWORD propcount;
88 DWORD prop;
89 PROPERTYKEY pkey;
90 BOOL found_name = FALSE;
91 BOOL found_desc = FALSE;
92 char temp[128];
93 temp[sizeof(temp)-1] = 0;
95 hr = IPropertyStore_GetCount(store, &propcount);
97 ok(hr == S_OK, "Failed with %08x\n", hr);
98 ok(propcount > 0, "Propcount %d should be greather than zero\n", propcount);
100 for (prop = 0; prop < propcount; prop++) {
101 hr = IPropertyStore_GetAt(store, prop, &pkey);
102 ok(hr == S_OK, "Failed with %08x\n", hr);
103 if (IsEqualPropertyKey(pkey, DEVPKEY_Device_FriendlyName))
104 found_name = TRUE;
105 if (IsEqualPropertyKey(pkey, DEVPKEY_Device_DeviceDesc))
106 found_desc = TRUE;
108 ok(found_name || broken(!found_name), "DEVPKEY_Device_FriendlyName not found\n");
109 ok(found_desc == TRUE, "DEVPKEY_Device_DeviceDesc not found\n");
112 START_TEST(propstore)
114 HRESULT hr;
115 IMMDeviceEnumerator *mme = NULL;
116 IMMDevice *dev = NULL;
117 IPropertyStore *store;
119 CoInitializeEx(NULL, COINIT_MULTITHREADED);
120 hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&mme);
121 if (FAILED(hr))
123 skip("mmdevapi not available: 0x%08x\n", hr);
124 goto cleanup;
127 hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(mme, eRender, eMultimedia, &dev);
128 ok(hr == S_OK || hr == E_NOTFOUND, "GetDefaultAudioEndpoint failed: 0x%08x\n", hr);
129 if (hr != S_OK)
131 if (hr == E_NOTFOUND)
132 skip("No sound card available\n");
133 else
134 skip("GetDefaultAudioEndpoint returns 0x%08x\n", hr);
135 goto cleanup;
137 store = NULL;
138 hr = IMMDevice_OpenPropertyStore(dev, 3, &store);
139 ok(hr == E_INVALIDARG, "Wrong hr returned: %08x\n", hr);
140 if (hr != S_OK)
141 /* It seems on windows returning with E_INVALIDARG doesn't
142 * set store to NULL, so just don't set store to non-null
143 * before calling this function
145 ok(!store, "Store set to non-NULL on failure: %p/%08x\n", store, hr);
146 else if (store)
147 IPropertyStore_Release(store);
148 hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, NULL);
149 ok(hr == E_POINTER, "Wrong hr returned: %08x\n", hr);
151 store = NULL;
152 hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, &store);
153 ok(hr == S_OK, "Opening valid store returned %08x\n", hr);
154 if (store)
156 test_propertystore(store);
157 test_deviceinterface(store);
158 test_getat(store);
159 IPropertyStore_Release(store);
161 IMMDevice_Release(dev);
162 cleanup:
163 if (mme)
164 IMMDeviceEnumerator_Release(mme);
165 CoUninitialize();