[PATCH v14 0/1] MR10339: quartz/tests: Add tests for IMediaSeeking time formats in avisplit.
Added comprehensive tests for IMediaSeeking_ConvertTimeFormat. Replaced magic numbers with descriptive constants. Verified on Windows 10. Signed-off-by: José Luis Jiménez López josejl1987@gmail.com -- v14: quartz/tests/avisplit: Add tests for IMediaSeeking time formats. https://gitlab.winehq.org/wine/wine/-/merge_requests/10339
From: José Luis Jiménez López<josejl1987@gmail.com> Verified on Windows 10. Signed-off-by: José Luis Jiménez López <josejl1987@gmail.com> --- dlls/quartz/tests/avisplit.c | 149 +++++++++++++++++++++++++++++++---- 1 file changed, 132 insertions(+), 17 deletions(-) diff --git a/dlls/quartz/tests/avisplit.c b/dlls/quartz/tests/avisplit.c index cb756a07c5d..b93e80770df 100644 --- a/dlls/quartz/tests/avisplit.c +++ b/dlls/quartz/tests/avisplit.c @@ -1477,6 +1477,8 @@ static void test_seeking(void) { LONGLONG time, current, stop, prev_stop, earliest, latest, duration; const WCHAR *filename = load_resource(L"test.avi"); + const LONGLONG one_second = 10000000; + const LONGLONG one_msec = 10000; IBaseFilter *filter = create_avi_splitter(); IFilterGraph2 *graph = connect_input(filter, filename); IMediaSeeking *seeking; @@ -1493,17 +1495,72 @@ static void test_seeking(void) { const GUID *guid; HRESULT hr; + HRESULT hr_set_time; } format_tests[] = { - {&TIME_FORMAT_MEDIA_TIME, S_OK}, - {&TIME_FORMAT_FRAME, S_OK}, - - {&TIME_FORMAT_BYTE, S_FALSE}, - {&TIME_FORMAT_NONE, S_FALSE}, - {&TIME_FORMAT_SAMPLE, S_FALSE}, - {&TIME_FORMAT_FIELD, S_FALSE}, - {&testguid, S_FALSE}, + {&TIME_FORMAT_MEDIA_TIME, S_OK, S_OK}, + {&TIME_FORMAT_FRAME, S_OK, S_OK}, + {&TIME_FORMAT_BYTE, S_FALSE, E_INVALIDARG}, + {&TIME_FORMAT_NONE, S_FALSE, E_INVALIDARG}, + {&TIME_FORMAT_SAMPLE, S_FALSE, E_INVALIDARG}, + {&TIME_FORMAT_FIELD, S_FALSE, E_INVALIDARG}, + {&testguid, S_FALSE, E_INVALIDARG}, + }; + + const struct + { + const GUID *source_guid; + LONGLONG source_time; + const GUID *target_guid; + LONGLONG target_time; + HRESULT hr; + BOOL wine_todo; + } time_format_tests[] = + { + {&TIME_FORMAT_MEDIA_TIME, one_second, &TIME_FORMAT_MEDIA_TIME, one_second, S_OK}, + {&TIME_FORMAT_MEDIA_TIME, one_second, &TIME_FORMAT_FRAME, 1, S_OK, TRUE}, + {&TIME_FORMAT_MEDIA_TIME, one_second, &TIME_FORMAT_FIELD, 0, E_INVALIDARG}, + {&TIME_FORMAT_MEDIA_TIME, one_second, &TIME_FORMAT_SAMPLE, 1, S_OK, TRUE}, + {&TIME_FORMAT_MEDIA_TIME, one_second, &TIME_FORMAT_BYTE, 0, E_INVALIDARG}, + + {&TIME_FORMAT_FRAME, 30, &TIME_FORMAT_MEDIA_TIME, 30 * one_second, S_OK, TRUE}, + {&TIME_FORMAT_FRAME, 30, &TIME_FORMAT_FRAME, 30, S_OK, TRUE}, + {&TIME_FORMAT_FRAME, 30, &TIME_FORMAT_FIELD, 0, E_INVALIDARG}, + {&TIME_FORMAT_FRAME, 30, &TIME_FORMAT_SAMPLE, 0, E_INVALIDARG}, + {&TIME_FORMAT_FRAME, 30, &TIME_FORMAT_BYTE, 0, E_INVALIDARG}, + + {&TIME_FORMAT_FIELD, 60, &TIME_FORMAT_MEDIA_TIME, 0, E_INVALIDARG}, + {&TIME_FORMAT_FIELD, 60, &TIME_FORMAT_FRAME, 0, E_INVALIDARG}, + {&TIME_FORMAT_FIELD, 60, &TIME_FORMAT_FIELD, 60, S_OK, TRUE}, + {&TIME_FORMAT_FIELD, 60, &TIME_FORMAT_SAMPLE, 0, E_INVALIDARG}, + {&TIME_FORMAT_FIELD, 60, &TIME_FORMAT_BYTE, 0, E_INVALIDARG}, + + {&TIME_FORMAT_SAMPLE, 48000, &TIME_FORMAT_MEDIA_TIME, 48000 * one_second, S_OK, TRUE}, + {&TIME_FORMAT_SAMPLE, 48000, &TIME_FORMAT_FRAME, 0, E_INVALIDARG}, + {&TIME_FORMAT_SAMPLE, 48000, &TIME_FORMAT_FIELD, 0, E_INVALIDARG}, + {&TIME_FORMAT_SAMPLE, 48000, &TIME_FORMAT_SAMPLE, 48000, S_OK, TRUE}, + {&TIME_FORMAT_SAMPLE, 48000, &TIME_FORMAT_BYTE, 0, E_INVALIDARG}, + + {&TIME_FORMAT_BYTE, 192000, &TIME_FORMAT_MEDIA_TIME, 0, E_INVALIDARG}, + {&TIME_FORMAT_BYTE, 192000, &TIME_FORMAT_FRAME, 0, E_INVALIDARG}, + {&TIME_FORMAT_BYTE, 192000, &TIME_FORMAT_FIELD, 0, E_INVALIDARG}, + {&TIME_FORMAT_BYTE, 192000, &TIME_FORMAT_SAMPLE, 0, E_INVALIDARG}, + {&TIME_FORMAT_BYTE, 192000, &TIME_FORMAT_BYTE, 192000, S_OK, TRUE}, + + {&TIME_FORMAT_NONE, 1, &TIME_FORMAT_MEDIA_TIME, 0, E_INVALIDARG}, + {&TIME_FORMAT_MEDIA_TIME, one_second, &TIME_FORMAT_NONE, 0, E_INVALIDARG}, + }; + + const struct + { + LONGLONG media_time; + LONGLONG frame; + } rounding_tests[] = + { + {4999999, 0}, + {5000000, 0}, + {15000000, 1} }; IBaseFilter_FindPin(filter, L"Stream 00", &pin); @@ -1538,10 +1595,14 @@ static void test_seeking(void) for (i = 0; i < ARRAY_SIZE(format_tests); ++i) { hr = IMediaSeeking_IsFormatSupported(seeking, format_tests[i].guid); - todo_wine_if(i == 1) ok(hr == format_tests[i].hr, "Got hr %#lx for format %s.\n", + todo_wine_if(i == 1) + ok(hr == format_tests[i].hr, "Got hr %#lx for format %s.\n", hr, wine_dbgstr_guid(format_tests[i].guid)); } + hr = IMediaSeeking_SetTimeFormat(seeking, &TIME_FORMAT_MEDIA_TIME); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IMediaSeeking_QueryPreferredFormat(seeking, &format); ok(hr == S_OK, "Got hr %#lx.\n", hr); ok(IsEqualGUID(&format, &TIME_FORMAT_MEDIA_TIME), "Got format %s.\n", wine_dbgstr_guid(&format)); @@ -1555,6 +1616,60 @@ static void test_seeking(void) hr = IMediaSeeking_IsUsingTimeFormat(seeking, &TIME_FORMAT_FRAME); ok(hr == S_FALSE, "Got hr %#lx.\n", hr); + for (i = 0; i < ARRAY_SIZE(format_tests); ++i) + { + hr = IMediaSeeking_SetTimeFormat(seeking, format_tests[i].guid); + todo_wine_if(i == 1) + ok(hr == format_tests[i].hr_set_time, "Got hr %#lx for format %s.\n", + hr, wine_dbgstr_guid(format_tests[i].guid)); + } + + hr = IMediaSeeking_SetTimeFormat(seeking, &TIME_FORMAT_MEDIA_TIME); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + for (i = 0; i < ARRAY_SIZE(time_format_tests); ++i) + { + LONGLONG result = 0xdeadbeef; + + hr = IMediaSeeking_ConvertTimeFormat(seeking, &result, time_format_tests[i].target_guid, + time_format_tests[i].source_time, time_format_tests[i].source_guid); + + todo_wine_if(time_format_tests[i].wine_todo) + ok(hr == time_format_tests[i].hr, "test %u hr %#lx.\n", i, hr); + if (hr == S_OK) + { + todo_wine_if(time_format_tests[i].wine_todo) + ok(result == time_format_tests[i].target_time, "wrong value %s at test %u.\n", + wine_dbgstr_longlong(result), i); + } + else + { + ok(result == 0xdeadbeef, "result was modified at test %u: %s.\n", + i, wine_dbgstr_longlong(result)); + } + } + + for (i = 0; i < ARRAY_SIZE(rounding_tests); ++i) + { + LONGLONG result = 0xdeadbeef; + + hr = IMediaSeeking_ConvertTimeFormat(seeking, &result, &TIME_FORMAT_FRAME, + rounding_tests[i].media_time, &TIME_FORMAT_MEDIA_TIME); + + todo_wine ok(hr == S_OK, "test %u hr %#lx.\n", i, hr); + + if (hr == S_OK) + { + ok(result == rounding_tests[i].frame, + "wrong frame %s at test %u.\n", wine_dbgstr_longlong(result), i); + } + else + { + ok(result == 0xdeadbeef, "result was modified at test %u: %s.\n", + i, wine_dbgstr_longlong(result)); + } + } + hr = IMediaSeeking_SetTimeFormat(seeking, &TIME_FORMAT_SAMPLE); ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); hr = IMediaSeeking_SetTimeFormat(seeking, &TIME_FORMAT_FRAME); @@ -1575,7 +1690,7 @@ static void test_seeking(void) duration = 0; hr = IMediaSeeking_GetDuration(seeking, &duration); ok(hr == S_OK, "Got hr %#lx.\n", hr); - ok(duration == 50000000, "Got duration %I64d.\n", duration); + ok(duration == 5 * one_second, "Got duration %I64d.\n", duration); stop = current = 0xdeadbeef; hr = IMediaSeeking_GetStopPosition(seeking, &stop); @@ -1603,7 +1718,7 @@ static void test_seeking(void) time = 0xdeadbeef; hr = IMediaSeeking_ConvertTimeFormat(seeking, &time, NULL, 123, &TIME_FORMAT_FRAME); todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(time == 123 * 10000000, "Got time %s.\n", wine_dbgstr_longlong(time)); + todo_wine ok(time == 123 * one_second, "Got time %s.\n", wine_dbgstr_longlong(time)); earliest = latest = 0xdeadbeef; hr = IMediaSeeking_GetAvailable(seeking, &earliest, &latest); @@ -1630,13 +1745,13 @@ static void test_seeking(void) hr = IMediaSeeking_GetPreroll(seeking, &time); todo_wine ok(hr == E_NOTIMPL, "Got hr %#lx.\n", hr); - current = 1500 * 10000; - stop = 3500 * 10000; + current = 1500 * one_msec; + stop = 3500 * one_msec; hr = IMediaSeeking_SetPositions(seeking, ¤t, AM_SEEKING_AbsolutePositioning, &stop, AM_SEEKING_AbsolutePositioning); ok(hr == S_OK, "Got hr %#lx.\n", hr); - ok(current == 1500 * 10000, "Got time %s.\n", wine_dbgstr_longlong(current)); - ok(stop == 3500 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop)); + ok(current == 1500 * one_msec, "Got time %s.\n", wine_dbgstr_longlong(current)); + ok(stop == 3500 * one_msec, "Got time %s.\n", wine_dbgstr_longlong(stop)); stop = current = 0xdeadbeef; hr = IMediaSeeking_GetPositions(seeking, ¤t, &stop); @@ -1645,8 +1760,8 @@ static void test_seeking(void) ok(current > 0 && current < duration, "Got time %s.\n", wine_dbgstr_longlong(current)); ok(stop > 0 && stop < duration && stop > current, "Got time %s.\n", wine_dbgstr_longlong(stop)); - current = 1500 * 10000; - stop = 3500 * 10000; + current = 1500 * one_msec; + stop = 3500 * one_msec; hr = IMediaSeeking_SetPositions(seeking, ¤t, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime, &stop, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime); ok(hr == S_OK, "Got hr %#lx.\n", hr); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10339
Gentle ping on this MR. Please let me know if anything should be adjusted. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10339#note_133535
Sorry about that. ``` + const struct + { + LONGLONG media_time; + LONGLONG frame; + } rounding_tests[] = + { + {4999999, 0}, + {5000000, 0}, + {15000000, 1} }; ``` That works, but I don't see why you need the separate table? I was just thinking you could alter the values used in the time_format_tests[] table so that they're not all perfect. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10339#note_133586
No worries, that makes sense. I simply thought that it made sense to separate them by concern, but you make a good point. I'll fold them into `time_format_tests` table. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10339#note_133591
participants (1)
-
Elizabeth Figura (@zfigura) -
José Luis Jiménez López -
José Luis Jiménez López (@josejl1987)