windowscodecs: Add tests for IWICStream_Seek with memory streams.

This commit is contained in:
Tony Wasserka 2009-08-23 11:43:09 +02:00 committed by Alexandre Julliard
parent df90e5d120
commit 12354a84cb
1 changed files with 40 additions and 0 deletions

View File

@ -32,8 +32,12 @@ static void test_StreamOnMemory(void)
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
};
BYTE Memory[64];
LARGE_INTEGER LargeNull, LargeInt;
ULARGE_INTEGER uNewPos;
HRESULT hr;
LargeNull.QuadPart = 0;
memcpy(Memory, CmpMem, sizeof(CmpMem));
CoInitialize(NULL);
@ -70,6 +74,42 @@ static void test_StreamOnMemory(void)
ok(hr == S_OK, "InitializeFromMemory returned with %#x, expected %#x\n", hr, S_OK);
/* Seek */
hr = IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, &uNewPos);
ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK);
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_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL);
ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK);
LargeInt.HighPart = 1;
LargeInt.LowPart = 0;
hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_SET, &uNewPos);
ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "Seek returned with %#x, expected %#x\n", hr, HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW));
ok(uNewPos.HighPart == 0 && uNewPos.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.HighPart, uNewPos.LowPart, 0, 0);
LargeInt.QuadPart = sizeof(Memory) + 10;
hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_SET, &uNewPos);
ok(hr == E_INVALIDARG, "Seek returned with %#x, expected %#x\n", hr, E_INVALIDARG);
ok(uNewPos.HighPart == 0 && uNewPos.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.HighPart, uNewPos.LowPart, 0, 0);
LargeInt.QuadPart = 1;
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, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.HighPart, uNewPos.LowPart, 0, 0);
LargeInt.QuadPart = -1;
hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_END, &uNewPos);
ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK);
ok(uNewPos.HighPart == 0 && uNewPos.LowPart == sizeof(Memory) - 1, "bSeek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.HighPart, uNewPos.LowPart, 0, sizeof(Memory) - 1);
IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, &uNewPos); /* reset seek pointer */
LargeInt.QuadPart = -sizeof(Memory) - 5;
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_Release(pStream);
IWICStream_Release(pFactory);
CoUninitialize();