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

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


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

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

windowscodecs: Add tests for IWICStream_Write with memory streams.

---

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

diff --git a/dlls/windowscodecs/tests/stream.c b/dlls/windowscodecs/tests/stream.c
index 6528b20..89a238b 100644
--- a/dlls/windowscodecs/tests/stream.c
+++ b/dlls/windowscodecs/tests/stream.c
@@ -34,7 +34,7 @@ static void test_StreamOnMemory(void)
     BYTE Memory[64], MemBuf[64];
     LARGE_INTEGER LargeNull, LargeInt;
     ULARGE_INTEGER uNewPos;
-    ULONG uBytesRead;
+    ULONG uBytesRead, uBytesWritten;
     HRESULT hr;
 
     LargeNull.QuadPart = 0;
@@ -168,6 +168,45 @@ static void test_StreamOnMemory(void)
     IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL);
 
 
+    /* Write */
+    MemBuf[0] = CmpMem[0] + 1;
+    MemBuf[1] = CmpMem[1] + 1;
+    MemBuf[2] = CmpMem[2] + 1;
+    hr = IWICStream_Write(pStream, MemBuf, 3, &uBytesWritten);
+    ok(hr == S_OK, "Write returned with %#x, expected %#x\n", hr, S_OK);
+    if(SUCCEEDED(hr)) {
+        ok(uBytesWritten == 3, "Wrote %u bytes, expected %u\n", uBytesWritten, 3);
+        ok(memcmp(MemBuf, Memory, 3) == 0, "Wrote returned invalid data!\n"); /* make sure we're writing directly */
+
+        /* check whether the seek pointer has moved correctly */
+        IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos);
+        ok(uNewPos.HighPart == 0 && uNewPos.LowPart == uBytesWritten, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.HighPart, uNewPos.LowPart, 0, uBytesWritten);
+    }
+    IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL);
+
+    hr = IWICStream_Write(pStream, MemBuf, 0, &uBytesWritten);
+    ok(hr == S_OK, "Read returned with %#x, expected %#x\n", hr, S_OK);
+
+    hr = IWICStream_Write(pStream, NULL, 3, &uBytesWritten);
+    ok(hr == E_INVALIDARG, "Write returned with %#x, expected %#x\n", hr, E_INVALIDARG);
+    ok(uBytesWritten == 0, "Wrote %u bytes, expected %u\n", uBytesWritten, 0);
+    IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos);
+    ok(uNewPos.HighPart == 0 && uNewPos.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.HighPart, uNewPos.LowPart, 0, 0);
+
+    hr = IWICStream_Write(pStream, NULL, 0, &uBytesWritten);
+    ok(hr == E_INVALIDARG, "Write returned with %#x, expected %#x\n", hr, E_INVALIDARG);
+    ok(uBytesWritten == 0, "Wrote %u bytes, expected %u\n", uBytesWritten, 0);
+    IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos);
+    ok(uNewPos.HighPart == 0 && uNewPos.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.HighPart, uNewPos.LowPart, 0, 0);
+
+    hr = IWICStream_Write(pStream, CmpMem, sizeof(Memory) + 10, &uBytesWritten);
+    ok(hr == STG_E_MEDIUMFULL, "Write returned with %#x, expected %#x\n", hr, STG_E_MEDIUMFULL);
+    ok(uBytesWritten == 0, "Wrote %u bytes, expected %u\n", uBytesWritten, 0);
+    IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos);
+    ok(uNewPos.HighPart == 0 && uNewPos.LowPart == uBytesWritten, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.HighPart, uNewPos.LowPart, 0, uBytesWritten);
+    IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL);
+
+
     IWICStream_Release(pStream);
     IWICStream_Release(pFactory);
     CoUninitialize();




More information about the wine-cvs mailing list