Tony Wasserka : windowscodecs: Add tests for IWICStream_Read with memory streams.

Alexandre Julliard julliard at winehq.org
Mon Aug 24 10:09:17 CDT 2009


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

Author: Tony Wasserka <tony.wasserka at freenet.de>
Date:   Sun Aug 23 11:43:38 2009 +0200

windowscodecs: Add tests for IWICStream_Read with memory streams.

---

 dlls/windowscodecs/tests/stream.c |   60 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 1 deletions(-)

diff --git a/dlls/windowscodecs/tests/stream.c b/dlls/windowscodecs/tests/stream.c
index 255cf14..6528b20 100644
--- a/dlls/windowscodecs/tests/stream.c
+++ b/dlls/windowscodecs/tests/stream.c
@@ -31,9 +31,10 @@ static void test_StreamOnMemory(void)
         0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
         0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
     };
-    BYTE Memory[64];
+    BYTE Memory[64], MemBuf[64];
     LARGE_INTEGER LargeNull, LargeInt;
     ULARGE_INTEGER uNewPos;
+    ULONG uBytesRead;
     HRESULT hr;
 
     LargeNull.QuadPart = 0;
@@ -108,6 +109,63 @@ static void test_StreamOnMemory(void)
     hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_END, &uNewPos);
     ok(hr == E_INVALIDARG, "Seek returned with %#x, expected %#x\n", hr, E_INVALIDARG);
     ok(uNewPos.HighPart == 0 && uNewPos.LowPart == 0, "bSeek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.HighPart, uNewPos.LowPart, 0, 0); /* remains unchanged */
+    IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL);
+
+
+    /* Read */
+    hr = IWICStream_Read(pStream, MemBuf, 12, &uBytesRead);
+    ok(hr == S_OK, "Read returned with %#x, expected %#x\n", hr, S_OK);
+    if(SUCCEEDED(hr)) {
+        ok(uBytesRead == 12, "Read %u bytes, expected %u\n", uBytesRead, 3);
+        ok(memcmp(MemBuf, CmpMem, 12) == 0, "Read returned invalid data!\n");
+
+        /* check whether the seek pointer has moved correctly */
+        IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos);
+        ok(uNewPos.HighPart == 0 && uNewPos.LowPart == uBytesRead, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.HighPart, uNewPos.LowPart, 0, uBytesRead);
+    }
+
+    IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL);
+
+    hr = IWICStream_Read(pStream, Memory, 10, &uBytesRead);   /* source = dest */
+    ok(hr == S_OK, "Read returned with %#x, expected %#x\n", hr, S_OK);
+    if(SUCCEEDED(hr)) {
+        ok(uBytesRead == 10, "Read %u bytes, expected %u\n", uBytesRead, 10);
+        ok(memcmp(Memory, CmpMem, uBytesRead) == 0, "Read returned invalid data!\n");
+    }
+
+    IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL);
+
+    hr = IWICStream_Read(pStream, Memory, sizeof(Memory) + 10, &uBytesRead);   /* request too many bytes */
+    ok(hr == S_OK, "Read returned with %#x, expected %#x\n", hr, S_OK);
+    if(SUCCEEDED(hr)) {
+        ok(uBytesRead == sizeof(Memory), "Read %u bytes, expected %u\n", uBytesRead, sizeof(Memory));
+        ok(memcmp(Memory, CmpMem, uBytesRead) == 0, "Read returned invalid data!\n");
+    }
+
+    hr = IWICStream_Read(pStream, NULL, 1, &uBytesRead);    /* destination buffer = NULL */
+    ok(hr == E_INVALIDARG, "Read returned with %#x, expected %#x\n", hr, E_INVALIDARG);
+
+    hr = IWICStream_Read(pStream, MemBuf, 0, &uBytesRead);    /* read 0 bytes */
+    ok(hr == S_OK, "Read returned with %#x, expected %#x\n", hr, S_OK);
+
+    hr = IWICStream_Read(pStream, NULL, 0, &uBytesRead);
+    ok(hr == E_INVALIDARG, "Read returned with %#x, expected %#x\n", hr, E_INVALIDARG);
+
+    hr = IWICStream_Read(pStream, NULL, 0, NULL);
+    ok(hr == E_INVALIDARG, "Read returned with %#x, expected %#x\n", hr, E_INVALIDARG);
+
+    hr = IWICStream_Read(pStream, MemBuf, 1, NULL);
+    ok(hr == S_OK, "Read returned with %#x, expected %#x\n", hr, S_OK);
+
+    IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL);
+    ZeroMemory(MemBuf, sizeof(MemBuf));
+    hr = IWICStream_Read(pStream, MemBuf, sizeof(Memory) + 10, &uBytesRead);
+    ok(hr == S_OK, "Read returned with %#x, expected %#x\n", hr, S_OK);
+    if(SUCCEEDED(hr)) {
+        ok(uBytesRead == sizeof(Memory), "Read %u bytes, expected %u\n", uBytesRead, sizeof(Memory));
+        ok(memcmp(Memory, CmpMem, 64) == 0, "Read returned invalid data!\n");
+    }
+    IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL);
 
 
     IWICStream_Release(pStream);




More information about the wine-cvs mailing list