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

Alexandre Julliard julliard at winehq.org
Mon Feb 25 15:10:33 CST 2019


Module: wine
Branch: master
Commit: eccffa4872453ae2efe217ee7ed371ce2139219a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=eccffa4872453ae2efe217ee7ed371ce2139219a

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Fri Feb 22 19:27:02 2019 -0600

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

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/quartz/tests/memallocator.c | 91 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/dlls/quartz/tests/memallocator.c b/dlls/quartz/tests/memallocator.c
index ee6a409..53e5698 100644
--- a/dlls/quartz/tests/memallocator.c
+++ b/dlls/quartz/tests/memallocator.c
@@ -31,6 +31,96 @@ static IMemAllocator *create_allocator(void)
     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)
 {
     ALLOCATOR_PROPERTIES req_props = {2, 65536, 1, 0}, ret_props;
@@ -85,6 +175,7 @@ START_TEST(memallocator)
 {
     CoInitialize(NULL);
 
+    test_properties();
     test_commit();
 
     CoUninitialize();




More information about the wine-cvs mailing list