~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/mmdevapi/tests/mmdevenum.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Copyright 2009 Maarten Lankhorst
  3  *
  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.
  8  *
  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.
 13  *
 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
 17  */
 18 
 19 #include "wine/test.h"
 20 
 21 #define CINTERFACE
 22 #define COBJMACROS
 23 
 24 #include "initguid.h"
 25 #include "mmdeviceapi.h"
 26 #include "audioclient.h"
 27 #include "dshow.h"
 28 #include "dsound.h"
 29 #include "devpkey.h"
 30 
 31 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
 32 
 33 /* Some of the QueryInterface tests are really just to check if I got the IID's right :) */
 34 
 35 /* IMMDeviceCollection appears to have no QueryInterface method and instead forwards to mme */
 36 static void test_collection(IMMDeviceEnumerator *mme, IMMDeviceCollection *col)
 37 {
 38     IMMDeviceCollection *col2;
 39     IMMDeviceEnumerator *mme2;
 40     IUnknown *unk;
 41     HRESULT hr;
 42     ULONG ref;
 43     UINT numdev;
 44     IMMDevice *dev;
 45 
 46     /* collection doesn't keep a ref on parent */
 47     IUnknown_AddRef(mme);
 48     ref = IUnknown_Release(mme);
 49     ok(ref == 2, "Reference count on parent is %u\n", ref);
 50 
 51     ref = IUnknown_AddRef(col);
 52     IUnknown_Release(col);
 53     ok(ref == 2, "Invalid reference count %u on collection\n", ref);
 54 
 55     hr = IUnknown_QueryInterface(col, &IID_IUnknown, NULL);
 56     ok(hr == E_POINTER, "Null ppv returns %08x\n", hr);
 57 
 58     hr = IUnknown_QueryInterface(col, &IID_IUnknown, (void**)&unk);
 59     ok(hr == S_OK, "Cannot query for IID_IUnknown: 0x%08x\n", hr);
 60     if (hr == S_OK)
 61     {
 62         ok((LONG_PTR)col == (LONG_PTR)unk, "Pointers are not identical %p/%p/%p\n", col, unk, mme);
 63         IUnknown_Release(unk);
 64     }
 65 
 66     hr = IUnknown_QueryInterface(col, &IID_IMMDeviceCollection, (void**)&col2);
 67     ok(hr == S_OK, "Cannot query for IID_IMMDeviceCollection: 0x%08x\n", hr);
 68     if (hr == S_OK)
 69         IUnknown_Release(col2);
 70 
 71     hr = IUnknown_QueryInterface(col, &IID_IMMDeviceEnumerator, (void**)&mme2);
 72     ok(hr == E_NOINTERFACE, "Query for IID_IMMDeviceEnumerator returned: 0x%08x\n", hr);
 73     if (hr == S_OK)
 74         IUnknown_Release(mme2);
 75 
 76     hr = IMMDeviceCollection_GetCount(col, NULL);
 77     ok(hr == E_POINTER, "GetCount returned 0x%08x\n", hr);
 78 
 79     hr = IMMDeviceCollection_GetCount(col, &numdev);
 80     ok(hr == S_OK, "GetCount returned 0x%08x\n", hr);
 81 
 82     dev = (void*)(LONG_PTR)0x12345678;
 83     hr = IMMDeviceCollection_Item(col, numdev, &dev);
 84     ok(hr == E_INVALIDARG, "Asking for too high device returned 0x%08x\n", hr);
 85     ok(dev == NULL, "Returned non-null device\n");
 86 
 87     if (numdev)
 88     {
 89         hr = IMMDeviceCollection_Item(col, 0, NULL);
 90         ok(hr == E_POINTER, "Query with null pointer returned 0x%08x\n", hr);
 91 
 92         hr = IMMDeviceCollection_Item(col, 0, &dev);
 93         ok(hr == S_OK, "Valid Item returned 0x%08x\n", hr);
 94         ok(dev != NULL, "Device is null!\n");
 95         if (dev != NULL)
 96         {
 97             char temp[128];
 98             WCHAR *id = NULL;
 99             if (IMMDevice_GetId(dev, &id) == S_OK)
100             {
101                 temp[sizeof(temp)-1] = 0;
102                 WideCharToMultiByte(CP_ACP, 0, id, -1, temp, sizeof(temp)-1, NULL, NULL);
103                 trace("Device found: %s\n", temp);
104                 CoTaskMemFree(id);
105             }
106         }
107         if (dev)
108             IUnknown_Release(dev);
109     }
110     IUnknown_Release(col);
111 }
112 
113 /* Only do parameter tests here, the actual MMDevice testing should be a separate test */
114 START_TEST(mmdevenum)
115 {
116     HRESULT hr;
117     IUnknown *unk = NULL;
118     IMMDeviceEnumerator *mme, *mme2;
119     ULONG ref;
120     IMMDeviceCollection *col;
121 
122     CoInitializeEx(NULL, COINIT_MULTITHREADED);
123     hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&mme);
124     if (FAILED(hr))
125     {
126         skip("mmdevapi not available: 0x%08x\n", hr);
127         return;
128     }
129 
130     /* Odd behavior.. bug? */
131     ref = IUnknown_AddRef(mme);
132     ok(ref == 3, "Invalid reference count after incrementing: %u\n", ref);
133     IUnknown_Release(mme);
134 
135     hr = IUnknown_QueryInterface(mme, &IID_IUnknown, (void**)&unk);
136     ok(hr == S_OK, "returned 0x%08x\n", hr);
137     if (hr != S_OK) return;
138 
139     ok( (LONG_PTR)mme == (LONG_PTR)unk, "Pointers are unequal %p/%p\n", unk, mme);
140     IUnknown_Release(unk);
141 
142     /* Proving that it is static.. */
143     hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&mme2);
144     IUnknown_Release(mme2);
145     ok(mme == mme2, "Pointers are not equal!\n");
146 
147     hr = IUnknown_QueryInterface(mme, &IID_IUnknown, NULL);
148     ok(hr == E_POINTER, "Null pointer on QueryInterface returned %08x\n", hr);
149 
150     hr = IUnknown_QueryInterface(mme, &GUID_NULL, (void**)&unk);
151     ok(!unk, "Unk not reset to null after invalid QI\n");
152     ok(hr == E_NOINTERFACE, "Invalid hr %08x returned on IID_NULL\n", hr);
153 
154     col = (void*)(LONG_PTR)0x12345678;
155     hr = IMMDeviceEnumerator_EnumAudioEndpoints(mme, 0xffff, DEVICE_STATEMASK_ALL, &col);
156     ok(hr == E_INVALIDARG, "Setting invalid data flow returned 0x%08x\n", hr);
157     ok(col == NULL, "Collection pointer non-null on failure\n");
158 
159     hr = IMMDeviceEnumerator_EnumAudioEndpoints(mme, eAll, DEVICE_STATEMASK_ALL+1, &col);
160     ok(hr == E_INVALIDARG, "Setting invalid mask returned 0x%08x\n", hr);
161 
162     hr = IMMDeviceEnumerator_EnumAudioEndpoints(mme, eAll, DEVICE_STATEMASK_ALL, NULL);
163     ok(hr == E_POINTER, "Invalid pointer returned: 0x%08x\n", hr);
164 
165     hr = IMMDeviceEnumerator_EnumAudioEndpoints(mme, eAll, DEVICE_STATEMASK_ALL, &col);
166     ok(hr == S_OK, "Valid EnumAudioEndpoints returned 0x%08x\n", hr);
167     if (hr == S_OK)
168     {
169         ok(!!col, "Returned null pointer\n");
170         if (col)
171             test_collection(mme, col);
172     }
173 
174     IUnknown_Release(mme);
175 }
176 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.