Commit 7a81507f authored by Tony Wasserka's avatar Tony Wasserka Committed by Alexandre Julliard

windowscodecs: Add tests for IWICStream_Write with memory streams.

parent b5c71551
......@@ -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();
......
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