Commit b5c71551 authored by Tony Wasserka's avatar Tony Wasserka Committed by Alexandre Julliard

windowscodecs: Add tests for IWICStream_Read with memory streams.

parent 12354a84
......@@ -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);
......
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