[PATCH 01/11] mfplat/tests: Add more comprehensive media source tests.
Derek Lesho
dlesho at codeweavers.com
Wed Feb 5 13:25:32 CST 2020
On 2020-02-05 00:22, Nikolay Sivov wrote:
> On 2/4/20 8:17 PM, Derek Lesho wrote:
>> +static BOOL expect_event(IMFMediaEventGenerator *gen, struct
>> expected_event *expected, PROPVARIANT *out)
>> +{
>> + HRESULT hr;
>> + IMFMediaEvent *event;
>> + BOOL ret = TRUE;
>> +
>> + hr = IMFMediaEventGenerator_GetEvent(gen, 0, &event);
>> + ok(hr == S_OK, "Failed to get event from media source, hr
>> %#x.\n", hr);
>> + {
>> + HRESULT status_code;
>> + hr = IMFMediaEvent_GetStatus(event, &status_code);
>> + ok (hr == S_OK, "Failed to get status code, hr %#x.\n", hr);
>> + ok (status_code == expected->status_code, "Unexpected status
>> code %#x, expected %#x.\n",
>> + status_code, expected->status_code);
>> +
>> + if (hr != S_OK || status_code != expected->status_code)
>> + ret = FALSE;
>> + }
>> + {
>> + MediaEventType event_type;
>> + hr = IMFMediaEvent_GetType(event, &event_type);
>> + ok(hr == S_OK, "Failed to event type, hr %#x.\n", hr);
>> + ok(event_type == expected->type, "Unexpected event type %u,
>> expected %u.\n",
>> + event_type, expected->type);
>> +
>> + if (hr != S_OK || event_type != expected->type)
>> + ret = FALSE;
>> + }
>> + if (expected->extended_type)
>> + {
>> + GUID extended_type;
>> + BOOL is_equal;
>> + hr = IMFMediaEvent_GetExtendedType(event, &extended_type);
>> + ok(hr == S_OK, "Failed to get extended type, hr %#x.\n", hr);
>> + is_equal = IsEqualGUID(&extended_type,
>> expected->extended_type);
>> + ok(is_equal, "Unexpected extended type %s, expected %s.\n",
>> + debugstr_guid(&extended_type),
>> debugstr_guid(expected->extended_type));
>> +
>> + if (hr != S_OK || !is_equal)
>> + ret = FALSE;
>> + }
>> + if (out)
>> + {
>> + hr = IMFMediaEvent_GetValue(event, out);
>> + ok (hr == S_OK, "Failed to get value of event, hr %#x.\n", hr);
>> +
>> + if (hr != S_OK)
>> + ret = FALSE;
>> + }
>> + IMFMediaEvent_Release(event);
>> +
>> + return ret;
>> +}
> I don't understand the purpose of such code arrangement. If you want
> to test for equality, get all relevant attributes and use them in a
> single test condition. Once you have event object it's safe to assume
> that getters won't fail. If extended type is not used you might as
> well drop it from expected data and compare to a constant.
>
The event type, extended type, status, and value are all not stored in
the attributes, AFAIK. Right now, I haven't found a need to compare the
attributes, so I'm not sure how that would help. I do understand
wanting to remove the extended type check since we don't use it right
now though.
More information about the wine-devel
mailing list