3
3
4
4
#include " util.h"
5
5
6
- #include " winrt.h"
6
+ import <std.h>;
7
+ import <win.h>;
8
+ import test.winrt;
7
9
8
10
import test.errors;
9
- import test_stream;
11
+ import test.stream;
12
+ import test.util;
10
13
import factory;
11
14
12
- import <shlwapi.h>;
13
- import <wincodec.h>;
14
-
15
- import <vector>;
16
-
17
-
18
15
using namespace winrt ;
19
16
using namespace Microsoft ::VisualStudio::CppUnitTestFramework;
20
17
using std::vector;
@@ -29,7 +26,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
29
26
TEST_METHOD (GetContainerFormat) // NOLINT
30
27
{
31
28
GUID container_format;
32
- const hresult result{factory_.create_decoder ()->GetContainerFormat (&container_format)};
29
+ const auto result{factory_.create_decoder ()->GetContainerFormat (&container_format)};
33
30
34
31
Assert::AreEqual (error_ok, result);
35
32
Assert::IsTrue (container_format_netpbm == container_format);
@@ -38,7 +35,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
38
35
TEST_METHOD (GetContainerFormat_with_nullptr) // NOLINT
39
36
{
40
37
SUPPRESS_WARNING_6387_INVALID_ARGUMENT_NEXT_LINE
41
- const hresult result{factory_.create_decoder ()->GetContainerFormat (nullptr )};
38
+ const auto result{factory_.create_decoder ()->GetContainerFormat (nullptr )};
42
39
43
40
Assert::IsTrue (failed (result));
44
41
}
@@ -48,7 +45,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
48
45
com_ptr<IWICBitmapDecoder> decoder = factory_.create_decoder ();
49
46
50
47
com_ptr<IWICBitmapDecoderInfo> decoder_info;
51
- const hresult result{decoder->GetDecoderInfo (decoder_info.put ())};
48
+ const auto result{decoder->GetDecoderInfo (decoder_info.put ())};
52
49
53
50
Assert::IsTrue (result == error_ok || result == wincodec::error_component_not_found);
54
51
if (succeeded (result))
@@ -64,31 +61,31 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
64
61
TEST_METHOD (GetDecoderInfo_with_nullptr) // NOLINT
65
62
{
66
63
SUPPRESS_WARNING_6387_INVALID_ARGUMENT_NEXT_LINE
67
- const hresult result{factory_.create_decoder ()->GetDecoderInfo (nullptr )};
64
+ const auto result{factory_.create_decoder ()->GetDecoderInfo (nullptr )};
68
65
69
66
Assert::IsTrue (failed (result));
70
67
}
71
68
72
69
TEST_METHOD (CopyPalette) // NOLINT
73
70
{
74
71
const com_ptr<IWICPalette> palette;
75
- const hresult result{factory_.create_decoder ()->CopyPalette (palette.get ())};
72
+ const auto result{factory_.create_decoder ()->CopyPalette (palette.get ())};
76
73
77
74
Assert::AreEqual (wincodec::error_palette_unavailable, result);
78
75
}
79
76
80
77
TEST_METHOD (GetMetadataQueryReader) // NOLINT
81
78
{
82
79
com_ptr<IWICMetadataQueryReader> metadata_query_reader;
83
- const hresult result{factory_.create_decoder ()->GetMetadataQueryReader (metadata_query_reader.put ())};
80
+ const auto result{factory_.create_decoder ()->GetMetadataQueryReader (metadata_query_reader.put ())};
84
81
85
82
Assert::AreEqual (wincodec::error_unsupported_operation, result);
86
83
}
87
84
88
85
TEST_METHOD (GetPreview) // NOLINT
89
86
{
90
87
com_ptr<IWICBitmapSource> bitmap_source;
91
- const hresult result{factory_.create_decoder ()->GetPreview (bitmap_source.put ())};
88
+ const auto result{factory_.create_decoder ()->GetPreview (bitmap_source.put ())};
92
89
93
90
Assert::AreEqual (wincodec::error_unsupported_operation, result);
94
91
}
@@ -97,7 +94,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
97
94
{
98
95
com_ptr<IWICColorContext> color_contexts;
99
96
uint32_t actual_count;
100
- const hresult result{factory_.create_decoder ()->GetColorContexts (1 , color_contexts.put (), &actual_count)};
97
+ const auto result{factory_.create_decoder ()->GetColorContexts (1 , color_contexts.put (), &actual_count)};
101
98
102
99
Assert::AreEqual (error_ok, result);
103
100
Assert::AreEqual (0U , actual_count);
@@ -106,15 +103,15 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
106
103
TEST_METHOD (GetThumbnail) // NOLINT
107
104
{
108
105
com_ptr<IWICBitmapSource> bitmap_source;
109
- const hresult result{factory_.create_decoder ()->GetThumbnail (bitmap_source.put ())};
106
+ const auto result{factory_.create_decoder ()->GetThumbnail (bitmap_source.put ())};
110
107
111
108
Assert::AreEqual (wincodec::error_codec_no_thumbnail, result);
112
109
}
113
110
114
111
TEST_METHOD (GetFrameCount) // NOLINT
115
112
{
116
113
uint32_t frame_count;
117
- const hresult result{factory_.create_decoder ()->GetFrameCount (&frame_count)};
114
+ const auto result{factory_.create_decoder ()->GetFrameCount (&frame_count)};
118
115
119
116
Assert::AreEqual (error_ok, result);
120
117
Assert::AreEqual (1U , frame_count);
@@ -123,7 +120,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
123
120
TEST_METHOD (GetFrameCount_count_parameter_is_null) // NOLINT
124
121
{
125
122
SUPPRESS_WARNING_6387_INVALID_ARGUMENT_NEXT_LINE
126
- const hresult result{factory_.create_decoder ()->GetFrameCount (nullptr )};
123
+ const auto result{factory_.create_decoder ()->GetFrameCount (nullptr )};
127
124
128
125
Assert::AreEqual (error_pointer, result);
129
126
}
@@ -134,7 +131,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
134
131
stream.attach (SHCreateMemStream (nullptr , 0 ));
135
132
136
133
DWORD capability;
137
- const hresult result{factory_.create_decoder ()->QueryCapability (stream.get (), &capability)};
134
+ const auto result{factory_.create_decoder ()->QueryCapability (stream.get (), &capability)};
138
135
139
136
Assert::AreEqual (error_ok, result);
140
137
Assert::AreEqual (0UL , capability);
@@ -143,7 +140,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
143
140
TEST_METHOD (QueryCapability_stream_argument_null) // NOLINT
144
141
{
145
142
DWORD capability;
146
- const hresult result{factory_.create_decoder ()->QueryCapability (nullptr , &capability)};
143
+ const auto result{factory_.create_decoder ()->QueryCapability (nullptr , &capability)};
147
144
148
145
Assert::AreEqual (error_invalid_argument, result);
149
146
}
@@ -154,7 +151,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
154
151
stream.attach (SHCreateMemStream (nullptr , 0 ));
155
152
156
153
SUPPRESS_WARNING_6387_INVALID_ARGUMENT_NEXT_LINE
157
- const hresult result{factory_.create_decoder ()->QueryCapability (stream.get (), nullptr )};
154
+ const auto result{factory_.create_decoder ()->QueryCapability (stream.get (), nullptr )};
158
155
159
156
Assert::AreEqual (error_pointer, result);
160
157
}
@@ -165,7 +162,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
165
162
check_hresult (
166
163
SHCreateStreamOnFileEx (L" tulips-gray-8bit-512-512.pgm" , STGM_READ | STGM_SHARE_DENY_WRITE, 0 , false , nullptr , stream.put ()));
167
164
DWORD capability;
168
- const hresult result{factory_.create_decoder ()->QueryCapability (stream.get (), &capability)};
165
+ const auto result{factory_.create_decoder ()->QueryCapability (stream.get (), &capability)};
169
166
170
167
Assert::AreEqual (error_ok, result);
171
168
Assert::AreEqual (static_cast <DWORD>(WICBitmapDecoderCapabilityCanDecodeAllImages), capability);
@@ -176,7 +173,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
176
173
com_ptr<IStream> stream{winrt::make<test_stream>(true , 2 )};
177
174
178
175
DWORD capability;
179
- const hresult result = factory_.create_decoder ()->QueryCapability (stream.get (), &capability);
176
+ const auto result = factory_.create_decoder ()->QueryCapability (stream.get (), &capability);
180
177
181
178
Assert::IsTrue (failed (result));
182
179
}
@@ -186,7 +183,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
186
183
com_ptr<IStream> stream{winrt::make<test_stream>(false , 1 )};
187
184
188
185
DWORD capability;
189
- const hresult result = factory_.create_decoder ()->QueryCapability (stream.get (), &capability);
186
+ const auto result = factory_.create_decoder ()->QueryCapability (stream.get (), &capability);
190
187
191
188
Assert::IsTrue (failed (result));
192
189
}
@@ -196,7 +193,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
196
193
com_ptr<IStream> stream{winrt::make<test_stream>(false , 2 )};
197
194
198
195
DWORD capability;
199
- const hresult result = factory_.create_decoder ()->QueryCapability (stream.get (), &capability);
196
+ const auto result = factory_.create_decoder ()->QueryCapability (stream.get (), &capability);
200
197
201
198
Assert::IsTrue (failed (result));
202
199
}
@@ -206,7 +203,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
206
203
com_ptr<IStream> stream;
207
204
stream.attach (SHCreateMemStream (nullptr , 0 ));
208
205
209
- const hresult result{factory_.create_decoder ()->Initialize (stream.get (), WICDecodeMetadataCacheOnDemand)};
206
+ const auto result{factory_.create_decoder ()->Initialize (stream.get (), WICDecodeMetadataCacheOnDemand)};
210
207
Assert::AreEqual (error_ok, result);
211
208
}
212
209
@@ -215,7 +212,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
215
212
com_ptr<IStream> stream;
216
213
stream.attach (SHCreateMemStream (nullptr , 0 ));
217
214
218
- const hresult result{factory_.create_decoder ()->Initialize (stream.get (), WICDecodeMetadataCacheOnLoad)};
215
+ const auto result{factory_.create_decoder ()->Initialize (stream.get (), WICDecodeMetadataCacheOnLoad)};
219
216
Assert::AreEqual (error_ok, result);
220
217
}
221
218
@@ -225,7 +222,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
225
222
stream.attach (SHCreateMemStream (nullptr , 0 ));
226
223
227
224
com_ptr<IWICBitmapDecoder> decoder = factory_.create_decoder ();
228
- hresult result{decoder->Initialize (stream.get (), WICDecodeMetadataCacheOnDemand)};
225
+ auto result{decoder->Initialize (stream.get (), WICDecodeMetadataCacheOnDemand)};
229
226
Assert::AreEqual (error_ok, result);
230
227
231
228
result = decoder->Initialize (stream.get (), WICDecodeMetadataCacheOnLoad);
@@ -237,15 +234,15 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
237
234
com_ptr<IStream> stream;
238
235
stream.attach (SHCreateMemStream (nullptr , 0 ));
239
236
240
- const hresult result{factory_.create_decoder ()->Initialize (stream.get (), static_cast <WICDecodeOptions>(4 ))};
237
+ const auto result{factory_.create_decoder ()->Initialize (stream.get (), static_cast <WICDecodeOptions>(4 ))};
241
238
242
239
// Cache options is not used by decoder and by design not validated.
243
240
Assert::AreEqual (error_ok, result);
244
241
}
245
242
246
243
TEST_METHOD (Initialize_null_stream) // NOLINT
247
244
{
248
- const hresult result{factory_.create_decoder ()->Initialize (nullptr , WICDecodeMetadataCacheOnDemand)};
245
+ const auto result{factory_.create_decoder ()->Initialize (nullptr , WICDecodeMetadataCacheOnDemand)};
249
246
Assert::AreEqual (error_invalid_argument, result);
250
247
}
251
248
@@ -256,7 +253,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
256
253
SHCreateStreamOnFileEx (L" tulips-gray-8bit-512-512.pgm" , STGM_READ | STGM_SHARE_DENY_WRITE, 0 , false , nullptr , stream.put ()));
257
254
258
255
com_ptr<IWICBitmapDecoder> decoder = factory_.create_decoder ();
259
- hresult result{decoder->Initialize (stream.get (), WICDecodeMetadataCacheOnDemand)};
256
+ auto result{decoder->Initialize (stream.get (), WICDecodeMetadataCacheOnDemand)};
260
257
Assert::AreEqual (error_ok, result);
261
258
262
259
uint32_t frame_count;
@@ -277,7 +274,7 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
277
274
SHCreateStreamOnFileEx (L" tulips-gray-8bit-512-512.pgm" , STGM_READ | STGM_SHARE_DENY_WRITE, 0 , false , nullptr , stream.put ()));
278
275
279
276
com_ptr<IWICBitmapDecoder> decoder = factory_.create_decoder ();
280
- hresult result{decoder->Initialize (stream.get (), WICDecodeMetadataCacheOnDemand)};
277
+ auto result{decoder->Initialize (stream.get (), WICDecodeMetadataCacheOnDemand)};
281
278
Assert::AreEqual (error_ok, result);
282
279
283
280
SUPPRESS_WARNING_6387_INVALID_ARGUMENT_NEXT_LINE
@@ -289,15 +286,15 @@ TEST_CLASS(netpbm_bitmap_decoder_test)
289
286
TEST_METHOD (GetFrame_with_bad_index) // NOLINT
290
287
{
291
288
com_ptr<IWICBitmapFrameDecode> bitmap_frame_decode;
292
- const hresult result{factory_.create_decoder ()->GetFrame (1 , bitmap_frame_decode.put ())};
289
+ const auto result{factory_.create_decoder ()->GetFrame (1 , bitmap_frame_decode.put ())};
293
290
294
291
Assert::AreEqual (wincodec::error_frame_missing, result);
295
292
}
296
293
297
294
TEST_METHOD (GetFrame_not_initialized) // NOLINT
298
295
{
299
296
com_ptr<IWICBitmapFrameDecode> bitmap_frame_decode;
300
- const hresult result{factory_.create_decoder ()->GetFrame (0 , bitmap_frame_decode.put ())};
297
+ const auto result{factory_.create_decoder ()->GetFrame (0 , bitmap_frame_decode.put ())};
301
298
302
299
Assert::AreEqual (wincodec::error_not_initialized, result);
303
300
}
0 commit comments