And split it into check_transform / enum_transform.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/mf/tests/mf.c | 159 ++++++++++++++++++++++++--------------------- 1 file changed, 86 insertions(+), 73 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 31a84e47bc1..d2b3b4f8901 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -162,6 +162,86 @@ static void check_attributes_(int line, IMFAttributes *attributes, const struct } }
+static BOOL check_transform(const GUID *class_id, const WCHAR *expect_name, + const media_type_desc *expect_input, ULONG expect_input_count, + const media_type_desc *expect_output, ULONG expect_output_count, + IMFTransform **transform) +{ + MFT_REGISTER_TYPE_INFO *input_types = NULL, *output_types = NULL; + UINT32 input_count = 0, output_count = 0, i; + WCHAR *name; + HRESULT hr; + + hr = MFTGetInfo(*class_id, &name, &input_types, &input_count, &output_types, &output_count, NULL); + if (FAILED(hr)) + { + todo_wine + win_skip("Failed to get %s info, skipping tests.\n", debugstr_w(expect_name)); + } + else + { + ok(hr == S_OK, "MFTEnum returned %lx\n", hr); + ok(!wcscmp(name, expect_name), "got name %s\n", debugstr_w(name)); + ok(input_count == expect_input_count, "got input_count %u\n", input_count); + for (i = 0; i < input_count; ++i) + { + ok(IsEqualGUID(&input_types[i].guidMajorType, expect_input[i][0].value.puuid), + "got input[%u] major %s\n", i, debugstr_guid(&input_types[i].guidMajorType)); + ok(IsEqualGUID(&input_types[i].guidSubtype, expect_input[i][1].value.puuid), + "got input[%u] subtype %s\n", i, debugstr_guid(&input_types[i].guidSubtype)); + } + ok(output_count == expect_output_count, "got output_count %u\n", output_count); + for (i = 0; i < output_count; ++i) + { + ok(IsEqualGUID(&output_types[i].guidMajorType, expect_output[i][0].value.puuid), + "got output[%u] major %s\n", i, debugstr_guid(&output_types[i].guidMajorType)); + ok(IsEqualGUID(&output_types[i].guidSubtype, expect_output[i][1].value.puuid), + "got output[%u] subtype %s\n", i, debugstr_guid(&output_types[i].guidSubtype)); + } + CoTaskMemFree(output_types); + CoTaskMemFree(input_types); + CoTaskMemFree(name); + } + + hr = CoCreateInstance(class_id, NULL, CLSCTX_INPROC_SERVER, &IID_IMFTransform, (void **)transform); + if (FAILED(hr)) + { + todo_wine + win_skip("Failed to create %s instance, skipping tests.\n", debugstr_w(expect_name)); + return FALSE; + } + + return TRUE; +} + +static BOOL enum_transform(GUID category, MFT_REGISTER_TYPE_INFO *input_type, + MFT_REGISTER_TYPE_INFO *output_type, const WCHAR *expect_name, + const media_type_desc *expect_input, ULONG expect_input_count, + const media_type_desc *expect_output, ULONG expect_output_count, + IMFTransform **transform, const GUID *expect_class_id, GUID *class_id) +{ + GUID *class_ids = NULL; + UINT32 count = 0; + HRESULT hr; + + hr = MFTEnum(category, 0, input_type, output_type, NULL, &class_ids, &count); + if (FAILED(hr)) + { + todo_wine + win_skip("Failed to enumerate %s, skipping tests.\n", debugstr_w(expect_name)); + return FALSE; + } + + ok(hr == S_OK, "MFTEnum returned %lx\n", hr); + ok(count == 1, "got %u\n", count); + *class_id = class_ids[0]; + CoTaskMemFree(class_ids); + ok(IsEqualGUID(class_id, expect_class_id), "got class id %s\n", debugstr_guid(class_id)); + + return check_transform(class_id, expect_name, expect_input, expect_input_count, + expect_output, expect_output_count, transform); +} + static HWND create_window(void) { RECT r = {0, 0, 640, 480}; @@ -5620,73 +5700,6 @@ static void test_MFRequireProtectedEnvironment(void) IMFPresentationDescriptor_Release(pd); }
-static BOOL create_transform(GUID category, MFT_REGISTER_TYPE_INFO *input_type, - MFT_REGISTER_TYPE_INFO *output_type, const WCHAR *expect_name, - const media_type_desc *expect_input, ULONG expect_input_count, - const media_type_desc *expect_output, ULONG expect_output_count, - IMFTransform **transform, GUID *class_id) -{ - MFT_REGISTER_TYPE_INFO *input_types = NULL, *output_types = NULL; - UINT32 input_count = 0, output_count = 0, count = 0, i; - GUID *class_ids = NULL; - WCHAR *name; - HRESULT hr; - - hr = MFTEnum(category, 0, input_type, output_type, NULL, &class_ids, &count); - if (FAILED(hr)) - { - todo_wine - win_skip("Failed to enumerate %s, skipping tests.\n", debugstr_w(expect_name)); - return FALSE; - } - - ok(hr == S_OK, "MFTEnum returned %lx\n", hr); - ok(count == 1, "got %u\n", count); - *class_id = class_ids[0]; - CoTaskMemFree(class_ids); - - hr = MFTGetInfo(*class_id, &name, &input_types, &input_count, &output_types, &output_count, NULL); - if (FAILED(hr)) - { - todo_wine - win_skip("Failed to get %s info, skipping tests.\n", debugstr_w(expect_name)); - } - else - { - ok(hr == S_OK, "MFTEnum returned %lx\n", hr); - ok(!wcscmp(name, expect_name), "got name %s\n", debugstr_w(name)); - ok(input_count == expect_input_count, "got input_count %u\n", input_count); - for (i = 0; i < input_count; ++i) - { - ok(IsEqualGUID(&input_types[i].guidMajorType, expect_input[i][0].value.puuid), - "got input[%u] major %s\n", i, debugstr_guid(&input_types[i].guidMajorType)); - ok(IsEqualGUID(&input_types[i].guidSubtype, expect_input[i][1].value.puuid), - "got input[%u] subtype %s\n", i, debugstr_guid(&input_types[i].guidSubtype)); - } - ok(output_count == expect_output_count, "got output_count %u\n", output_count); - for (i = 0; i < output_count; ++i) - { - ok(IsEqualGUID(&output_types[i].guidMajorType, expect_output[i][0].value.puuid), - "got output[%u] major %s\n", i, debugstr_guid(&output_types[i].guidMajorType)); - ok(IsEqualGUID(&output_types[i].guidSubtype, expect_output[i][1].value.puuid), - "got output[%u] subtype %s\n", i, debugstr_guid(&output_types[i].guidSubtype)); - } - CoTaskMemFree(output_types); - CoTaskMemFree(input_types); - CoTaskMemFree(name); - } - - hr = CoCreateInstance(class_id, NULL, CLSCTX_INPROC_SERVER, &IID_IMFTransform, (void **)transform); - if (FAILED(hr)) - { - todo_wine - win_skip("Failed to create %s instance, skipping tests.\n", debugstr_w(expect_name)); - return FALSE; - } - - return TRUE; -} - static IMFSample *create_sample(const BYTE *data, ULONG size) { IMFMediaBuffer *media_buffer; @@ -5820,9 +5833,9 @@ static void test_wma_encoder(void) hr = CoInitialize(NULL); ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
- if (!create_transform(MFT_CATEGORY_AUDIO_ENCODER, &input_type, &output_type, L"WMAudio Encoder MFT", + if (!enum_transform(MFT_CATEGORY_AUDIO_ENCODER, &input_type, &output_type, L"WMAudio Encoder MFT", transform_inputs, ARRAY_SIZE(transform_inputs), transform_outputs, ARRAY_SIZE(transform_outputs), - &transform, &class_id)) + &transform, &CLSID_CWMAEncMediaObject, &class_id)) goto failed;
check_interface(transform, &IID_IMediaObject, TRUE); @@ -6056,9 +6069,9 @@ static void test_wma_decoder(void) hr = CoInitialize(NULL); ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
- if (!create_transform(MFT_CATEGORY_AUDIO_DECODER, &input_type, &output_type, L"WMAudio Decoder MFT", + if (!enum_transform(MFT_CATEGORY_AUDIO_DECODER, &input_type, &output_type, L"WMAudio Decoder MFT", transform_inputs, ARRAY_SIZE(transform_inputs), transform_outputs, ARRAY_SIZE(transform_outputs), - &transform, &class_id)) + &transform, &CLSID_CWMADecMediaObject, &class_id)) goto failed;
check_interface(transform, &IID_IMediaObject, TRUE); @@ -6642,9 +6655,9 @@ static void test_h264_decoder(void) hr = CoInitialize(NULL); ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
- if (!create_transform(MFT_CATEGORY_VIDEO_DECODER, &input_type, &output_type, L"Microsoft H264 Video Decoder MFT", + if (!enum_transform(MFT_CATEGORY_VIDEO_DECODER, &input_type, &output_type, L"Microsoft H264 Video Decoder MFT", transform_inputs, ARRAY_SIZE(transform_inputs), transform_outputs, ARRAY_SIZE(transform_outputs), - &transform, &class_id)) + &transform, &CLSID_MSH264DecoderMFT, &class_id)) goto failed;
hr = IMFTransform_GetAttributes(transform, &attributes);