include/mscvpdb.h: Use flexible array members for the rest of structures.
[wine.git] / dlls / windows.media / tests / captions.c
blobc496a8503fbdc0c20ca6f2fd21cc0c874acc5c87
1 /*
2 * Copyright (C) 2022 Mohamad Al-Jaf
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
18 #define COBJMACROS
19 #include "initguid.h"
20 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winstring.h"
26 #include "roapi.h"
28 #define WIDL_using_Windows_Foundation
29 #define WIDL_using_Windows_Foundation_Collections
30 #include "windows.foundation.h"
31 #define WIDL_using_Windows_UI
32 #include "windows.ui.h"
33 #define WIDL_using_Windows_Media_ClosedCaptioning
34 #include "windows.media.closedcaptioning.h"
36 #include "wine/test.h"
38 #define check_interface( obj, iid, exp ) check_interface_( __LINE__, obj, iid, exp )
39 static void check_interface_( unsigned int line, void *obj, const IID *iid, BOOL supported )
41 IUnknown *iface = obj;
42 IUnknown *unk;
43 HRESULT hr, expected_hr;
45 expected_hr = supported ? S_OK : E_NOINTERFACE;
47 hr = IUnknown_QueryInterface( iface, iid, (void **)&unk );
48 ok_( __FILE__, line )( hr == expected_hr || broken(hr == E_NOINTERFACE ), "Got hr %#lx, expected %#lx.\n", hr, expected_hr );
49 if (SUCCEEDED(hr))
50 IUnknown_Release( unk );
53 static void test_CaptionStatics(void)
55 static const WCHAR *caption_properties_name = L"Windows.Media.ClosedCaptioning.ClosedCaptionProperties";
56 IClosedCaptionPropertiesStatics *caption_statics;
57 IActivationFactory *factory;
58 HSTRING str;
59 HRESULT hr;
60 LONG ref;
61 /* Properties */
62 ClosedCaptionColor color;
63 ClosedCaptionOpacity opacity;
64 ClosedCaptionSize size;
65 ClosedCaptionStyle style;
66 ClosedCaptionEdgeEffect effect;
67 Color computed_color;
69 hr = WindowsCreateString( caption_properties_name, wcslen( caption_properties_name ), &str );
70 ok( hr == S_OK, "got hr %#lx.\n", hr );
72 hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory );
73 WindowsDeleteString( str );
74 ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "got hr %#lx.\n", hr );
75 if (hr == REGDB_E_CLASSNOTREG)
77 win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( caption_properties_name ));
78 return;
81 check_interface( factory, &IID_IUnknown, TRUE );
82 check_interface( factory, &IID_IInspectable, TRUE );
83 check_interface( factory, &IID_IAgileObject, FALSE );
85 hr = IActivationFactory_QueryInterface( factory, &IID_IClosedCaptionPropertiesStatics, (void **)&caption_statics );
86 ok( hr == S_OK, "got hr %#lx.\n", hr );
88 color = 0xdeadbeef;
89 hr = IClosedCaptionPropertiesStatics_get_FontColor( caption_statics, &color );
90 ok( hr == S_OK, "get_FontColor returned %#lx\n", hr );
91 ok( color == ClosedCaptionColor_Default, "expected default font color, got %d\n", color );
93 hr = IClosedCaptionPropertiesStatics_get_ComputedFontColor( caption_statics, &computed_color );
94 todo_wine ok( hr == E_INVALIDARG, "get_ComputedFontColor returned %#lx\n", hr );
95 hr = IClosedCaptionPropertiesStatics_get_ComputedFontColor( caption_statics, NULL );
96 todo_wine ok( hr == E_INVALIDARG, "get_ComputedFontColor returned %#lx\n", hr );
98 opacity = 0xdeadbeef;
99 hr = IClosedCaptionPropertiesStatics_get_FontOpacity( caption_statics, &opacity );
100 ok( hr == S_OK, "get_FontOpacity returned %#lx\n", hr );
101 ok( opacity == ClosedCaptionOpacity_Default, "expected default font opacity, got %d\n", opacity );
103 size = 0xdeadbeef;
104 hr = IClosedCaptionPropertiesStatics_get_FontSize( caption_statics, &size );
105 ok( hr == S_OK, "get_FontSize returned %#lx\n", hr );
106 ok( size == ClosedCaptionSize_Default, "expected default font size, got %d\n", size );
108 style = 0xdeadbeef;
109 hr = IClosedCaptionPropertiesStatics_get_FontStyle( caption_statics, &style );
110 ok( hr == S_OK, "get_FontStyle returned %#lx\n", hr );
111 ok( style == ClosedCaptionStyle_Default, "expected default font style, got %d\n", style );
113 effect = 0xdeadbeef;
114 hr = IClosedCaptionPropertiesStatics_get_FontEffect( caption_statics, &effect );
115 ok( hr == S_OK, "get_FontEffect returned %#lx\n", hr );
116 ok( effect == ClosedCaptionEdgeEffect_Default, "expected default font effect, got %d\n", effect );
118 color = 0xdeadbeef;
119 hr = IClosedCaptionPropertiesStatics_get_BackgroundColor( caption_statics, &color );
120 ok( hr == S_OK, "get_BackgroundColor returned %#lx\n", hr );
121 ok( color == ClosedCaptionColor_Default, "expected default background color, got %d\n", color );
123 hr = IClosedCaptionPropertiesStatics_get_ComputedBackgroundColor( caption_statics, &computed_color );
124 todo_wine ok( hr == E_INVALIDARG, "get_ComputedBackgroundColor returned %#lx\n", hr );
125 hr = IClosedCaptionPropertiesStatics_get_ComputedBackgroundColor( caption_statics, NULL );
126 todo_wine ok( hr == E_INVALIDARG, "get_ComputedBackgroundColor returned %#lx\n", hr );
128 opacity = 0xdeadbeef;
129 hr = IClosedCaptionPropertiesStatics_get_BackgroundOpacity( caption_statics, &opacity );
130 ok( hr == S_OK, "get_BackgroundOpacity returned %#lx\n", hr );
131 ok( opacity == ClosedCaptionOpacity_Default, "expected default background opacity, got %d\n", opacity );
133 color = 0xdeadbeef;
134 hr = IClosedCaptionPropertiesStatics_get_RegionColor( caption_statics, &color );
135 ok( hr == S_OK, "get_RegionColor returned %#lx\n", hr );
136 ok( color == ClosedCaptionColor_Default, "expected default region color, got %d\n", color );
138 hr = IClosedCaptionPropertiesStatics_get_ComputedRegionColor( caption_statics, &computed_color );
139 todo_wine ok( hr == E_INVALIDARG, "get_ComputedRegionColor returned %#lx\n", hr );
140 hr = IClosedCaptionPropertiesStatics_get_ComputedRegionColor( caption_statics, NULL );
141 todo_wine ok( hr == E_INVALIDARG, "get_ComputedRegionColor returned %#lx\n", hr );
143 opacity = 0xdeadbeef;
144 hr = IClosedCaptionPropertiesStatics_get_RegionOpacity( caption_statics, &opacity );
145 ok( hr == S_OK, "get_RegionOpacity returned %#lx\n", hr );
146 ok( opacity == ClosedCaptionOpacity_Default, "expected default region opacity, got %d\n", opacity );
148 ref = IClosedCaptionPropertiesStatics_Release( caption_statics );
149 ok( ref == 2, "got ref %ld.\n", ref );
150 ref = IActivationFactory_Release( factory );
151 ok( ref == 1, "got ref %ld.\n", ref );
154 START_TEST(captions)
156 HRESULT hr;
158 hr = RoInitialize( RO_INIT_MULTITHREADED );
159 ok( hr == S_OK, "RoInitialize failed, hr %#lx\n", hr );
161 test_CaptionStatics();
163 RoUninitialize();