From 97405fc805d455ce4e8e8762e57b338723a05b4c Mon Sep 17 00:00:00 2001 From: Akihiro Sagawa Date: Fri, 25 Nov 2016 01:08:50 +0900 Subject: [PATCH] quartz: Add tests for IBasicVideo. Signed-off-by: Akihiro Sagawa Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/quartz/tests/filtergraph.c | 208 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c index 87b11233ba4..fa11d3f3ef6 100644 --- a/dlls/quartz/tests/filtergraph.c +++ b/dlls/quartz/tests/filtergraph.c @@ -50,6 +50,212 @@ static int createfiltergraph(void) &CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IGraphBuilder, (LPVOID*)&pgraph); } +static void test_basic_video(void) +{ + IBasicVideo* pbv; + LONG video_width, video_height; + LONG left, top, width, height; + HRESULT hr; + + hr = IGraphBuilder_QueryInterface(pgraph, &IID_IBasicVideo, (LPVOID*)&pbv); + ok(hr==S_OK, "Cannot get IBasicVideo interface returned: %x\n", hr); + + /* test get video size */ + hr = IBasicVideo_GetVideoSize(pbv, NULL, NULL); + ok(hr==E_POINTER, "IBasicVideo_GetVideoSize returned: %x\n", hr); + hr = IBasicVideo_GetVideoSize(pbv, &video_width, NULL); + ok(hr==E_POINTER, "IBasicVideo_GetVideoSize returned: %x\n", hr); + hr = IBasicVideo_GetVideoSize(pbv, NULL, &video_height); + ok(hr==E_POINTER, "IBasicVideo_GetVideoSize returned: %x\n", hr); + hr = IBasicVideo_GetVideoSize(pbv, &video_width, &video_height); + ok(hr==S_OK, "Cannot get video size returned: %x\n", hr); + + /* test source position */ + hr = IBasicVideo_GetSourcePosition(pbv, NULL, NULL, NULL, NULL); + ok(hr == E_POINTER, "IBasicVideo_GetSourcePosition returned: %x\n", hr); + hr = IBasicVideo_GetSourcePosition(pbv, &left, &top, NULL, NULL); + ok(hr == E_POINTER, "IBasicVideo_GetSourcePosition returned: %x\n", hr); + hr = IBasicVideo_GetSourcePosition(pbv, NULL, NULL, &width, &height); + ok(hr == E_POINTER, "IBasicVideo_GetSourcePosition returned: %x\n", hr); + hr = IBasicVideo_GetSourcePosition(pbv, &left, &top, &width, &height); + ok(hr == S_OK, "Cannot get source position returned: %x\n", hr); + ok(left == 0, "expected 0, got %d\n", left); + ok(top == 0, "expected 0, got %d\n", top); + ok(width == video_width, "expected %d, got %d\n", video_width, width); + ok(height == video_height, "expected %d, got %d\n", video_height, height); + + hr = IBasicVideo_SetSourcePosition(pbv, 0, 0, 0, 0); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_SetSourcePosition returned: %x\n", hr); + hr = IBasicVideo_SetSourcePosition(pbv, 0, 0, video_width*2, video_height*2); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_SetSourcePosition returned: %x\n", hr); + hr = IBasicVideo_put_SourceTop(pbv, -1); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_put_SourceTop returned: %x\n", hr); + hr = IBasicVideo_put_SourceTop(pbv, 0); + ok(hr==S_OK, "Cannot put source top returned: %x\n", hr); + hr = IBasicVideo_put_SourceTop(pbv, 1); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_put_SourceTop returned: %x\n", hr); + + hr = IBasicVideo_SetSourcePosition(pbv, video_width, 0, video_width, video_height); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_SetSourcePosition returned: %x\n", hr); + hr = IBasicVideo_SetSourcePosition(pbv, 0, video_height, video_width, video_height); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_SetSourcePosition returned: %x\n", hr); + hr = IBasicVideo_SetSourcePosition(pbv, -1, 0, video_width, video_height); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_SetSourcePosition returned: %x\n", hr); + hr = IBasicVideo_SetSourcePosition(pbv, 0, -1, video_width, video_height); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_SetSourcePosition returned: %x\n", hr); + hr = IBasicVideo_SetSourcePosition(pbv, video_width/2, video_height/2, video_width, video_height); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_SetSourcePosition returned: %x\n", hr); + hr = IBasicVideo_SetSourcePosition(pbv, video_width/2, video_height/2, video_width, video_height); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_SetSourcePosition returned: %x\n", hr); + + hr = IBasicVideo_SetSourcePosition(pbv, 0, 0, video_width, video_height+1); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_SetSourcePosition returned: %x\n", hr); + hr = IBasicVideo_SetSourcePosition(pbv, 0, 0, video_width+1, video_height); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_SetSourcePosition returned: %x\n", hr); + + hr = IBasicVideo_SetSourcePosition(pbv, video_width/2, video_height/2, video_width/3+1, video_height/3+1); + ok(hr==S_OK, "Cannot set source position returned: %x\n", hr); + + hr = IBasicVideo_get_SourceLeft(pbv, &left); + ok(hr==S_OK, "Cannot get source left returned: %x\n", hr); + ok(left==video_width/2, "expected %d, got %d\n", video_width/2, left); + hr = IBasicVideo_get_SourceTop(pbv, &top); + ok(hr==S_OK, "Cannot get source top returned: %x\n", hr); + ok(top==video_height/2, "expected %d, got %d\n", video_height/2, top); + hr = IBasicVideo_get_SourceWidth(pbv, &width); + ok(hr==S_OK, "Cannot get source width returned: %x\n", hr); + ok(width==video_width/3+1, "expected %d, got %d\n", video_width/3+1, width); + hr = IBasicVideo_get_SourceHeight(pbv, &height); + ok(hr==S_OK, "Cannot get source height returned: %x\n", hr); + ok(height==video_height/3+1, "expected %d, got %d\n", video_height/3+1, height); + + hr = IBasicVideo_put_SourceLeft(pbv, video_width/3); + ok(hr==S_OK, "Cannot put source left returned: %x\n", hr); + hr = IBasicVideo_GetSourcePosition(pbv, &left, &top, &width, &height); + ok(hr == S_OK, "Cannot get source position returned: %x\n", hr); + ok(left == video_width/3, "expected %d, got %d\n", video_width/3, left); + todo_wine ok(width == video_width/3+1, "expected %d, got %d\n", video_width/3+1, width); + + hr = IBasicVideo_put_SourceTop(pbv, video_height/3); + ok(hr==S_OK, "Cannot put source top returned: %x\n", hr); + hr = IBasicVideo_GetSourcePosition(pbv, &left, &top, &width, &height); + ok(hr == S_OK, "Cannot get source position returned: %x\n", hr); + ok(top == video_height/3, "expected %d, got %d\n", video_height/3, top); + todo_wine ok(height == video_height/3+1, "expected %d, got %d\n", video_height/3+1, height); + + hr = IBasicVideo_put_SourceWidth(pbv, video_width/4+1); + ok(hr==S_OK, "Cannot put source width returned: %x\n", hr); + hr = IBasicVideo_GetSourcePosition(pbv, &left, &top, &width, &height); + ok(hr == S_OK, "Cannot get source position returned: %x\n", hr); + ok(left == video_width/3, "expected %d, got %d\n", video_width/3, left); + ok(width == video_width/4+1, "expected %d, got %d\n", video_width/4+1, width); + + hr = IBasicVideo_put_SourceHeight(pbv, video_height/4+1); + ok(hr==S_OK, "Cannot put source height returned: %x\n", hr); + hr = IBasicVideo_GetSourcePosition(pbv, &left, &top, &width, &height); + ok(hr == S_OK, "Cannot get source position returned: %x\n", hr); + ok(top == video_height/3, "expected %d, got %d\n", video_height/3, top); + ok(height == video_height/4+1, "expected %d, got %d\n", video_height/4+1, height); + + /* test desination rectangle */ + hr = IBasicVideo_GetDestinationPosition(pbv, NULL, NULL, NULL, NULL); + ok(hr == E_POINTER, "IBasicVideo_GetDestinationPosition returned: %x\n", hr); + hr = IBasicVideo_GetDestinationPosition(pbv, &left, &top, NULL, NULL); + ok(hr == E_POINTER, "IBasicVideo_GetDestinationPosition returned: %x\n", hr); + hr = IBasicVideo_GetDestinationPosition(pbv, NULL, NULL, &width, &height); + ok(hr == E_POINTER, "IBasicVideo_GetDestinationPosition returned: %x\n", hr); + hr = IBasicVideo_GetDestinationPosition(pbv, &left, &top, &width, &height); + ok(hr == S_OK, "Cannot get destination position returned: %x\n", hr); + ok(left == 0, "expected 0, got %d\n", left); + ok(top == 0, "expected 0, got %d\n", top); + todo_wine ok(width == video_width, "expected %d, got %d\n", video_width, width); + todo_wine ok(height == video_height, "expected %d, got %d\n", video_height, height); + + hr = IBasicVideo_SetDestinationPosition(pbv, 0, 0, 0, 0); + todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_SetDestinationPosition returned: %x\n", hr); + hr = IBasicVideo_SetDestinationPosition(pbv, 0, 0, video_width*2, video_height*2); + ok(hr==S_OK, "Cannot put destination position returned: %x\n", hr); + + hr = IBasicVideo_put_DestinationLeft(pbv, -1); + ok(hr==S_OK, "Cannot put destination left returned: %x\n", hr); + hr = IBasicVideo_put_DestinationLeft(pbv, 0); + ok(hr==S_OK, "Cannot put destination left returned: %x\n", hr); + hr = IBasicVideo_put_DestinationLeft(pbv, 1); + ok(hr==S_OK, "Cannot put destination left returned: %x\n", hr); + + hr = IBasicVideo_SetDestinationPosition(pbv, video_width, 0, video_width, video_height); + ok(hr==S_OK, "Cannot set destinaiton position returned: %x\n", hr); + hr = IBasicVideo_SetDestinationPosition(pbv, 0, video_height, video_width, video_height); + ok(hr==S_OK, "Cannot set destinaiton position returned: %x\n", hr); + hr = IBasicVideo_SetDestinationPosition(pbv, -1, 0, video_width, video_height); + ok(hr==S_OK, "Cannot set destination position returned: %x\n", hr); + hr = IBasicVideo_SetDestinationPosition(pbv, 0, -1, video_width, video_height); + ok(hr==S_OK, "Cannot set destination position returned: %x\n", hr); + hr = IBasicVideo_SetDestinationPosition(pbv, video_width/2, video_height/2, video_width, video_height); + ok(hr==S_OK, "Cannot set destination position returned: %x\n", hr); + hr = IBasicVideo_SetDestinationPosition(pbv, video_width/2, video_height/2, video_width, video_height); + ok(hr==S_OK, "Cannot set destination position returned: %x\n", hr); + + hr = IBasicVideo_SetDestinationPosition(pbv, 0, 0, video_width, video_height+1); + ok(hr==S_OK, "Cannot set destination position returned: %x\n", hr); + hr = IBasicVideo_SetDestinationPosition(pbv, 0, 0, video_width+1, video_height); + ok(hr==S_OK, "Cannot set destination position returned: %x\n", hr); + + hr = IBasicVideo_SetDestinationPosition(pbv, video_width/2, video_height/2, video_width/3+1, video_height/3+1); + ok(hr==S_OK, "Cannot set destination position returned: %x\n", hr); + + hr = IBasicVideo_get_DestinationLeft(pbv, &left); + ok(hr==S_OK, "Cannot get destination left returned: %x\n", hr); + ok(left==video_width/2, "expected %d, got %d\n", video_width/2, left); + hr = IBasicVideo_get_DestinationTop(pbv, &top); + ok(hr==S_OK, "Cannot get destination top returned: %x\n", hr); + ok(top==video_height/2, "expected %d, got %d\n", video_height/2, top); + hr = IBasicVideo_get_DestinationWidth(pbv, &width); + ok(hr==S_OK, "Cannot get destination width returned: %x\n", hr); + ok(width==video_width/3+1, "expected %d, got %d\n", video_width/3+1, width); + hr = IBasicVideo_get_DestinationHeight(pbv, &height); + ok(hr==S_OK, "Cannot get destination height returned: %x\n", hr); + todo_wine ok(height==video_height/3+1, "expected %d, got %d\n", video_height/3+1, height); + + hr = IBasicVideo_put_DestinationLeft(pbv, video_width/3); + ok(hr==S_OK, "Cannot put destination left returned: %x\n", hr); + hr = IBasicVideo_GetDestinationPosition(pbv, &left, &top, &width, &height); + ok(hr == S_OK, "Cannot get source position returned: %x\n", hr); + ok(left == video_width/3, "expected %d, got %d\n", video_width/3, left); + todo_wine ok(width == video_width/3+1, "expected %d, got %d\n", video_width/3+1, width); + + hr = IBasicVideo_put_DestinationTop(pbv, video_height/3); + ok(hr==S_OK, "Cannot put destination top returned: %x\n", hr); + hr = IBasicVideo_GetDestinationPosition(pbv, &left, &top, &width, &height); + ok(hr == S_OK, "Cannot get source position returned: %x\n", hr); + ok(top == video_height/3, "expected %d, got %d\n", video_height/3, top); + todo_wine ok(height == video_height/3+1, "expected %d, got %d\n", video_height/3+1, height); + + hr = IBasicVideo_put_DestinationWidth(pbv, video_width/4+1); + ok(hr==S_OK, "Cannot put destination width returned: %x\n", hr); + hr = IBasicVideo_GetDestinationPosition(pbv, &left, &top, &width, &height); + ok(hr == S_OK, "Cannot get source position returned: %x\n", hr); + ok(left == video_width/3, "expected %d, got %d\n", video_width/3, left); + ok(width == video_width/4+1, "expected %d, got %d\n", video_width/4+1, width); + + hr = IBasicVideo_put_DestinationHeight(pbv, video_height/4+1); + ok(hr==S_OK, "Cannot put destination height returned: %x\n", hr); + hr = IBasicVideo_GetDestinationPosition(pbv, &left, &top, &width, &height); + ok(hr == S_OK, "Cannot get source position returned: %x\n", hr); + ok(top == video_height/3, "expected %d, got %d\n", video_height/3, top); + todo_wine ok(height == video_height/4+1, "expected %d, got %d\n", video_height/4+1, height); + + /* reset source rectangle */ + hr = IBasicVideo_SetDefaultSourcePosition(pbv); + ok(hr==S_OK, "IBasicVideo_SetDefaultSourcePosition returned: %x\n", hr); + + /* reset destination position */ + hr = IBasicVideo_SetDestinationPosition(pbv, 0, 0, video_width, video_height); + ok(hr==S_OK, "Cannot set destination position returned: %x\n", hr); + + IBasicVideo_Release(pbv); +} + static void rungraph(void) { HRESULT hr; @@ -70,6 +276,8 @@ static void rungraph(void) IMediaFilter_Release(pmf); + test_basic_video(); + hr = IMediaControl_Run(pmc); ok(hr==S_FALSE, "Cannot run the graph returned: %x\n", hr); -- 2.11.4.GIT