strmbase: do not lock in BaseOutputPinImpl_GetDeliveryBuffer the MemInputPin will...
[wine] / dlls / devenum / tests / devenum.c
1 /*
2  * Some unit tests for devenum
3  *
4  * Copyright (C) 2012 Christian Costa
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #define COBJMACROS
22
23 #include <stdio.h>
24
25 #include "wine/test.h"
26 #include "initguid.h"
27 #include "ole2.h"
28 #include "strmif.h"
29 #include "uuids.h"
30
31 static const WCHAR friendly_name[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
32
33 struct category
34 {
35     const char * name;
36     const GUID * clsid;
37 };
38
39 static struct category am_categories[] =
40 {
41     { "Legacy AM Filter category", &CLSID_LegacyAmFilterCategory },
42     { "Audio renderer category", &CLSID_AudioRendererCategory },
43     { "Midi renderer category", &CLSID_MidiRendererCategory },
44     { "Audio input device category", &CLSID_AudioInputDeviceCategory },
45     { "Video input device category", &CLSID_VideoInputDeviceCategory },
46     { "Audio compressor category", &CLSID_AudioCompressorCategory },
47     { "Video compressor category", &CLSID_VideoCompressorCategory }
48 };
49
50 static void test_devenum(void)
51 {
52     HRESULT res;
53     ICreateDevEnum* create_devenum;
54     IEnumMoniker* enum_moniker = NULL;
55     int i;
56
57     CoInitialize(NULL);
58
59     res = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
60                            &IID_ICreateDevEnum, (LPVOID*)&create_devenum);
61     if (res != S_OK) {
62         skip("Cannot create SystemDeviceEnum object (%x)\n", res);
63         CoUninitialize();
64         return;
65     }
66
67     trace("\n");
68
69     for (i = 0; i < (sizeof(am_categories) / sizeof(struct category)); i++)
70     {
71         trace("%s:\n", am_categories[i].name);
72
73         res = ICreateDevEnum_CreateClassEnumerator(create_devenum, am_categories[i].clsid, &enum_moniker, 0);
74         ok(SUCCEEDED(res), "Cannot create enum moniker (res = %x)\n", res);
75         if (res == S_OK)
76         {
77             IMoniker* moniker;
78             while (IEnumMoniker_Next(enum_moniker, 1, &moniker, NULL) == S_OK)
79             {
80                 IPropertyBag* prop_bag = NULL;
81                 VARIANT var;
82                 HRESULT hr;
83
84                 VariantInit(&var);
85                 hr = IMoniker_BindToStorage(moniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&prop_bag);
86                 ok(hr == S_OK, "IMoniker_BindToStorage failed with error %x\n", hr);
87
88                 if (SUCCEEDED(hr))
89                 {
90                     hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL);
91                     ok((hr == S_OK) || broken(hr == 0x80070002), "IPropertyBag_Read failed with error %x\n", hr);
92
93                     if (SUCCEEDED(hr))
94                     {
95                         trace("  %s\n", wine_dbgstr_w(V_UNION(&var, bstrVal)));
96                         VariantClear(&var);
97                     }
98                     else
99                     {
100                         trace("  ???\n");
101                     }
102                 }
103
104                 if (prop_bag)
105                     IPropertyBag_Release(prop_bag);
106                 IMoniker_Release(moniker);
107             }
108             IEnumMoniker_Release(enum_moniker);
109         }
110
111         trace("\n");
112     }
113
114     ICreateDevEnum_Release(create_devenum);
115
116     CoUninitialize();
117 }
118
119 /* CLSID_CDeviceMoniker */
120
121 START_TEST(devenum)
122 {
123     test_devenum();
124 }