quartz/tests: Add initial tests for IFileSourceFilter interface. (v3)

Andrew Eikum aeikum at codeweavers.com
Fri Apr 29 09:00:02 CDT 2016


Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>

On Fri, Apr 29, 2016 at 11:05:35AM +0200, Sebastian Lackner wrote:
> Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
> ---
> Changes in v3:
> * Fix a typo in one of the size values (thanks Michael).
> 
> Replaces 121935, the rest of the series stays valid.
> 
>  dlls/quartz/tests/avisplitter.c |  118 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 118 insertions(+)
> 
> diff --git a/dlls/quartz/tests/avisplitter.c b/dlls/quartz/tests/avisplitter.c
> index 2fa7f91..fe1069d 100644
> --- a/dlls/quartz/tests/avisplitter.c
> +++ b/dlls/quartz/tests/avisplitter.c
> @@ -169,6 +169,123 @@ static void test_basefilter(void)
>      IBaseFilter_Release(base);
>  }
>  
> +static void test_filesourcefilter(void)
> +{
> +    static const WCHAR prefix[] = {'w','i','n',0};
> +    static const struct
> +    {
> +        const char *label;
> +        const char *data;
> +        DWORD size;
> +        const GUID *subtype;
> +    }
> +    tests[] =
> +    {
> +        {
> +            "AVI",
> +            "\x52\x49\x46\x46xxxx\x41\x56\x49\x20",
> +            12,
> +            &MEDIASUBTYPE_Avi,
> +        },
> +        {
> +            "MPEG1 System",
> +            "\x00\x00\x01\xBA\x21\x00\x01\x00\x01\x80\x00\x01\x00\x00\x01\xBB",
> +            16,
> +            &MEDIASUBTYPE_MPEG1System,
> +        },
> +        {
> +            "MPEG1 Video",
> +            "\x00\x00\x01\xB3",
> +            4,
> +            &MEDIASUBTYPE_MPEG1Video,
> +        },
> +        {
> +            "MPEG1 Audio",
> +            "\xFF\xE0",
> +            2,
> +            &MEDIASUBTYPE_MPEG1Audio,
> +        },
> +        {
> +            "WAVE",
> +            "\x52\x49\x46\x46xxxx\x57\x41\x56\x45",
> +            12,
> +            &MEDIASUBTYPE_WAVE,
> +        },
> +    };
> +    WCHAR path[MAX_PATH], temp[MAX_PATH];
> +    IFileSourceFilter *filesource;
> +    DWORD ret, written;
> +    IBaseFilter *base;
> +    AM_MEDIA_TYPE mt;
> +    OLECHAR *olepath;
> +    BOOL success;
> +    HANDLE file;
> +    HRESULT hr;
> +    int i;
> +
> +    ret = GetTempPathW(MAX_PATH, temp);
> +    ok(ret, "GetTempPathW failed with error %u\n", GetLastError());
> +    ret = GetTempFileNameW(temp, prefix, 0, path);
> +    ok(ret, "GetTempFileNameW failed with error %u\n", GetLastError());
> +
> +    for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> +    {
> +        trace("Running test for %s\n", tests[i].label);
> +
> +        file = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, 0, NULL,
> +                           CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
> +        ok(file != INVALID_HANDLE_VALUE, "CreateFileW failed with error %u\n", GetLastError());
> +        success = WriteFile(file, tests[i].data, tests[i].size, &written, NULL);
> +        ok(success, "WriteFile failed with error %u\n", GetLastError());
> +        ok(written == tests[i].size, "could not write test data\n");
> +        CloseHandle(file);
> +
> +        hr = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER,
> +                              &IID_IBaseFilter, (void **)&base);
> +        ok(hr == S_OK, "CoCreateInstance failed with %08x\n", hr);
> +        hr = IBaseFilter_QueryInterface(base, &IID_IFileSourceFilter, (void **)&filesource);
> +        ok(hr == S_OK, "IBaseFilter_QueryInterface failed with %08x\n", hr);
> +
> +        olepath = (void *)0xdeadbeef;
> +        hr = IFileSourceFilter_GetCurFile(filesource, &olepath, NULL);
> +        ok(hr == S_OK, "expected S_OK, got %08x\n", hr);
> +        ok(olepath == NULL, "expected NULL, got %p\n", olepath);
> +
> +        hr = IFileSourceFilter_Load(filesource, NULL, NULL);
> +        todo_wine
> +        ok(hr == E_POINTER, "expected E_POINTER, got %08x\n", hr);
> +
> +        hr = IFileSourceFilter_Load(filesource, path, NULL);
> +        ok(hr == S_OK, "IFileSourceFilter_Load failed with %08x\n", hr);
> +
> +        hr = IFileSourceFilter_GetCurFile(filesource, NULL, &mt);
> +        ok(hr == E_POINTER, "expected E_POINTER, got %08x\n", hr);
> +
> +        olepath = NULL;
> +        hr = IFileSourceFilter_GetCurFile(filesource, &olepath, NULL);
> +        ok(hr == S_OK, "expected S_OK, got %08x\n", hr);
> +        CoTaskMemFree(olepath);
> +
> +        olepath = NULL;
> +        memset(&mt, 0x11, sizeof(mt));
> +        hr = IFileSourceFilter_GetCurFile(filesource, &olepath, &mt);
> +        ok(hr == S_OK, "expected S_OK, got %08x\n", hr);
> +        ok(!lstrcmpW(olepath, path),
> +           "expected %s, got %s\n", wine_dbgstr_w(path), wine_dbgstr_w(olepath));
> +        ok(IsEqualGUID(&mt.majortype, &MEDIATYPE_Stream),
> +           "expected MEDIATYPE_Stream, got %s\n", wine_dbgstr_guid(&mt.majortype));
> +        ok(IsEqualGUID(&mt.subtype, tests[i].subtype),
> +           "expected %s, got %s\n", wine_dbgstr_guid(tests[i].subtype), wine_dbgstr_guid(&mt.subtype));
> +        CoTaskMemFree(olepath);
> +
> +        IFileSourceFilter_Release(filesource);
> +        IBaseFilter_Release(base);
> +
> +        success = DeleteFileW(path);
> +        ok(success, "DeleteFileW failed with error %u\n", GetLastError());
> +    }
> +}
> +
>  static const WCHAR wfile[] = {'t','e','s','t','.','a','v','i',0};
>  static const char afile[] = "test.avi";
>  
> @@ -462,6 +579,7 @@ START_TEST(avisplitter)
>  
>      test_query_interface();
>      test_basefilter();
> +    test_filesourcefilter();
>      test_threads();
>  
>      release_avisplitter();
> -- 
> 2.8.0
> 
> 



More information about the wine-patches mailing list