Commit eccffa48 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

quartz/tests: Add tests for IMemAllocator_GetProperties() and IMemAllocator_SetProperties().

parent 83dc6673
...@@ -31,6 +31,96 @@ static IMemAllocator *create_allocator(void) ...@@ -31,6 +31,96 @@ static IMemAllocator *create_allocator(void)
return allocator; return allocator;
} }
static void test_properties(void)
{
ALLOCATOR_PROPERTIES req_props = {0}, ret_props;
IMemAllocator *allocator = create_allocator();
IMediaSample *sample;
LONG size, ret_size;
unsigned int i;
HRESULT hr;
static const ALLOCATOR_PROPERTIES tests[] =
{
{0, 0, 1, 0},
{1, 0, 1, 0},
{1, 1, 1, 0},
{1, 1, 4, 0},
{2, 1, 1, 0},
{1, 2, 4, 0},
{1, 1, 16, 0},
{1, 16, 16, 0},
{1, 17, 16, 0},
{1, 32, 16, 0},
{1, 1, 16, 1},
{1, 15, 16, 1},
{1, 16, 16, 1},
{1, 17, 16, 1},
{1, 0, 16, 16},
{1, 1, 16, 16},
{1, 16, 16, 16},
};
memset(&ret_props, 0xcc, sizeof(ret_props));
hr = IMemAllocator_GetProperties(allocator, &ret_props);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!ret_props.cBuffers, "Got %d buffers.\n", ret_props.cBuffers);
ok(!ret_props.cbBuffer, "Got size %d.\n", ret_props.cbBuffer);
ok(!ret_props.cbAlign, "Got align %d.\n", ret_props.cbAlign);
ok(!ret_props.cbPrefix, "Got prefix %d.\n", ret_props.cbPrefix);
hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
ok(hr == VFW_E_BADALIGN, "Got hr %#x.\n", hr);
for (i = 0; i < ARRAY_SIZE(tests); i++)
{
req_props = tests[i];
hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
ok(hr == S_OK, "Test %u: Got hr %#x.\n", i, hr);
ok(!memcmp(&req_props, &tests[i], sizeof(req_props)), "Test %u: Requested props should not be changed.\n", i);
ok(ret_props.cBuffers == req_props.cBuffers, "Test %u: Got %d buffers.\n", i, ret_props.cBuffers);
ok(ret_props.cbBuffer >= req_props.cbBuffer, "Test %u: Got size %d.\n", i, ret_props.cbBuffer);
ok(ret_props.cbAlign == req_props.cbAlign, "Test %u: Got alignment %d.\n", i, ret_props.cbAlign);
ok(ret_props.cbPrefix == req_props.cbPrefix, "Test %u: Got prefix %d.\n", i, ret_props.cbPrefix);
ret_size = ret_props.cbBuffer;
hr = IMemAllocator_GetProperties(allocator, &ret_props);
ok(hr == S_OK, "Test %u: Got hr %#x.\n", i, hr);
ok(ret_props.cBuffers == req_props.cBuffers, "Test %u: Got %d buffers.\n", i, ret_props.cBuffers);
ok(ret_props.cbBuffer == ret_size, "Test %u: Got size %d.\n", i, ret_props.cbBuffer);
ok(ret_props.cbAlign == req_props.cbAlign, "Test %u: Got alignment %d.\n", i, ret_props.cbAlign);
ok(ret_props.cbPrefix == req_props.cbPrefix, "Test %u: Got prefix %d.\n", i, ret_props.cbPrefix);
hr = IMemAllocator_Commit(allocator);
if (!req_props.cbBuffer)
{
ok(hr == VFW_E_SIZENOTSET, "Test %u: Got hr %#x.\n", i, hr);
continue;
}
ok(hr == S_OK, "Test %u: Got hr %#x.\n", i, hr);
hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
ok(hr == VFW_E_ALREADY_COMMITTED, "Test %u: Got hr %#x.\n", i, hr);
hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
ok(hr == S_OK, "Test %u: Got hr %#x.\n", i, hr);
size = IMediaSample_GetSize(sample);
ok(size == ret_size, "Test %u: Got size %d.\n", i, size);
hr = IMemAllocator_Decommit(allocator);
ok(hr == S_OK, "Test %u: Got hr %#x.\n", i, hr);
hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props);
ok(hr == VFW_E_BUFFERS_OUTSTANDING, "Test %u: Got hr %#x.\n", i, hr);
hr = IMediaSample_Release(sample);
ok(hr == S_OK, "Test %u: Got hr %#x.\n", i, hr);
}
IMemAllocator_Release(allocator);
}
static void test_commit(void) static void test_commit(void)
{ {
ALLOCATOR_PROPERTIES req_props = {2, 65536, 1, 0}, ret_props; ALLOCATOR_PROPERTIES req_props = {2, 65536, 1, 0}, ret_props;
...@@ -85,6 +175,7 @@ START_TEST(memallocator) ...@@ -85,6 +175,7 @@ START_TEST(memallocator)
{ {
CoInitialize(NULL); CoInitialize(NULL);
test_properties();
test_commit(); test_commit();
CoUninitialize(); CoUninitialize();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment