[PATCH 10/12] windowscodecs: Add tests for IWICStream_Write with memory streams
Tony Wasserka
tony.wasserka at freenet.de
Tue Aug 18 09:01:08 CDT 2009
---
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 37467c9..33db065 100644
--- a/dlls/windowscodecs/tests/stream.c
+++ b/dlls/windowscodecs/tests/stream.c
@@ -34,7 +34,7 @@ static void test_StreamOnMemory()
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()
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();
--
1.6.3.3
--------------010602060308040507060107--
More information about the wine-patches
mailing list