32#define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
36#define CHECK_EXPECTED_METHOD(method_name) \
38 ok(*expected_method_list != NULL, "Extra method %s called\n", method_name); \
39 if (*expected_method_list) \
41 ok(!strcmp(*expected_method_list, method_name), "Expected %s to be called instead of %s\n", \
42 *expected_method_list, method_name); \
43 expected_method_list++; \
49 const char data[] =
"Test String";
59 ok(
hr ==
S_OK,
"Failed to create a stream, hr %#x.\n",
hr);
62 hr = IStream_SetSize(pStream, ull);
69 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET,
NULL);
80 hr = IStream_SetSize(pStream, ull);
86 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_CUR,
NULL);
90 ull.
u.HighPart = 0xCAFECAFE;
91 ull.
u.LowPart = 0xCAFECAFE;
94 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_CUR, &ull);
96 ok(ull.
u.LowPart ==
sizeof(
data),
"LowPart set to %d\n", ull.
u.LowPart);
97 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
100 ull.
u.HighPart = 0xCAFECAFE;
101 ull.
u.LowPart = 0xCAFECAFE;
104 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_END+1, &ull);
105 ok(
hr ==
STG_E_SEEKERROR,
"IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n",
hr);
106 ok(ull.
u.LowPart ==
sizeof(
data),
"LowPart set to %d\n", ull.
u.LowPart);
107 ok(ull.
u.HighPart == 0,
"should not have changed HighPart, got %d\n", ull.
u.HighPart);
110 ull.
u.HighPart = 0xCAFECAFE;
111 ull.
u.LowPart = 0xCAFECAFE;
114 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET, &ull);
116 ok(ull.
u.LowPart == 0,
"should have set LowPart to 0 instead of %d\n", ull.
u.LowPart);
117 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
120 ull.
u.HighPart = 0xCAFECAFE;
121 ull.
u.LowPart = 0xCAFECAFE;
124 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_END, &ull);
126 ok(ull.
u.LowPart == 0,
"should have set LowPart to 0 instead of %d\n", ull.
u.LowPart);
127 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
131 ll.u.LowPart =
sizeof(
data);
132 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET, &ull);
135 ull.
u.HighPart = 0xCAFECAFE;
136 ull.
u.LowPart = 0xCAFECAFE;
139 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_CUR, &ull);
141 ok(ull.
u.LowPart ==
sizeof(
data),
"LowPart set to %d\n", ull.
u.LowPart);
142 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
146 ll.u.LowPart =
sizeof(
data);
147 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET, &ull);
150 ull.
u.HighPart = 0xCAFECAFE;
151 ull.
u.LowPart = 0xCAFECAFE;
154 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET, &ull);
156 ok(ull.
u.LowPart == 0,
"should have set LowPart to 0 instead of %d\n", ull.
u.LowPart);
157 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
161 ll.u.LowPart =
sizeof(
data);
162 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET, &ull);
165 ull.
u.HighPart = 0xCAFECAFE;
166 ull.
u.LowPart = 0xCAFECAFE;
168 ll.u.LowPart = 0x80000000;
169 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_CUR, &ull);
170 ok(
hr ==
STG_E_SEEKERROR,
"IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n",
hr);
171 ok(ull.
u.LowPart ==
sizeof(
data),
"LowPart set to %d\n", ull.
u.LowPart);
172 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
176 ll.u.LowPart =
sizeof(
data);
177 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET, &ull);
180 ull.
u.HighPart = 0xCAFECAFE;
181 ull.
u.LowPart = 0xCAFECAFE;
184 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_CUR, &ull);
186 ok(ull.
u.LowPart == 0,
"LowPart set to %d\n", ull.
u.LowPart);
187 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
191 ll.u.LowPart =
sizeof(
data);
192 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET, &ull);
195 ull.
u.HighPart = 0xCAFECAFE;
196 ull.
u.LowPart = 0xCAFECAFE;
199 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_CUR, &ull);
200 ok(
hr ==
STG_E_SEEKERROR,
"IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n",
hr);
201 ok(ull.
u.LowPart ==
sizeof(
data),
"LowPart set to %d\n", ull.
u.LowPart);
202 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
206 ll.u.LowPart =
sizeof(
data);
207 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET, &ull);
210 ull.
u.HighPart = 0xCAFECAFE;
211 ull.
u.LowPart = 0xCAFECAFE;
213 ll.u.LowPart = 0x80000000 -
sizeof(
data);
214 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_CUR, &ull);
216 ok(ull.
u.LowPart == 0x80000000,
"LowPart set to %d\n", ull.
u.LowPart);
217 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
221 ll.u.LowPart =
sizeof(
data);
222 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET, &ull);
225 ull.
u.HighPart = 0xCAFECAFE;
226 ull.
u.LowPart = 0xCAFECAFE;
228 ll.u.LowPart = 0x80000000;
229 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET, &ull);
230 ok(
hr ==
STG_E_SEEKERROR,
"IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n",
hr);
231 ok(ull.
u.LowPart ==
sizeof(
data),
"LowPart set to %d\n", ull.
u.LowPart);
232 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
235 ull.
u.HighPart = 0xCAFECAFE;
236 ull.
u.LowPart = 0xCAFECAFE;
238 ll.u.LowPart = 0x7FFFFFFF;
239 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET, &ull);
241 ok(ull.
u.LowPart == 0x7FFFFFFF,
"should have set LowPart to 0x7FFFFFFF instead of %08x\n", ull.
u.LowPart);
242 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
247 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_SET, &ull);
250 ull.
u.HighPart = 0xCAFECAFE;
251 ull.
u.LowPart = 0xCAFECAFE;
253 ll.u.LowPart = 0x7FFFFFFF;
254 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_CUR, &ull);
256 ok(ull.
u.LowPart == 0x7FFFFFFF,
"should have set LowPart to 0x7FFFFFFF instead of %08x\n", ull.
u.LowPart);
257 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
260 ull.
u.HighPart = 0xCAFECAFE;
261 ull.
u.LowPart = 0xCAFECAFE;
264 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_CUR, &ull);
266 ok(ull.
u.LowPart == 0x80000008,
"should have set LowPart to 0x80000008 instead of %08x\n", ull.
u.LowPart);
267 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
270 ull.
u.HighPart = 0xCAFECAFE;
271 ull.
u.LowPart = 0xCAFECAFE;
273 ll.u.LowPart = 0x7FFFFFFF;
274 hr = IStream_Seek(pStream,
ll, STREAM_SEEK_CUR, &ull);
277 ok(ull.
u.LowPart == 0x00000007,
"should have set LowPart to 0x00000007 instead of %08x\n", ull.
u.LowPart);
279 ok(ull.
u.LowPart == 0x80000008,
"should have set LowPart to 0x80000008 instead of %08x\n", ull.
u.LowPart);
280 ok(ull.
u.HighPart == 0,
"should have set HighPart to 0 instead of %d\n", ull.
u.HighPart);
282 hr = IStream_Commit(pStream, STGC_DEFAULT);
285 hr = IStream_Revert(pStream);
288 hr = IStream_LockRegion(pStream, ull, ull, LOCK_WRITE);
291 hr = IStream_Stat(pStream, &statstg, STATFLAG_DEFAULT);
293 ok(statstg.type == STGTY_STREAM,
"statstg.type should have been STGTY_STREAM instead of %d\n", statstg.type);
298 hr = IStream_SetSize(pStream, ull);
300 "IStream_SetSize with large size should have returned E_OUTOFMEMORY instead of 0x%08x\n",
hr);
302 IStream_Release(pStream);
312 IStream_AddRef(iface);
420 static const char szHello[] =
"Hello";
422 static const char *methods_copyto[] =
438 hr = IStream_Write(pStream, szHello,
sizeof(szHello), &written);
440 ok(written ==
sizeof(szHello),
"only %d bytes written\n", written);
442 hr = IStream_Seek(pStream,
llZero, STREAM_SEEK_SET,
NULL);
445 cb.QuadPart =
sizeof(szHello);
453 hr = IStream_Clone(pStream, &pStream2);
456 hr = IStream_Seek(pStream2,
llZero, STREAM_SEEK_CUR, &libNewPosition);
458 ok(libNewPosition.
QuadPart ==
sizeof(szHello),
"libNewPosition wasn't set correctly for the cloned stream\n");
460 hr = IStream_Seek(pStream2,
llZero, STREAM_SEEK_SET,
NULL);
465 ok(!
strcmp(
buffer, szHello),
"read data \"%s\" didn't match originally written data\n",
buffer);
467 IStream_Release(pStream2);
468 IStream_Release(pStream);
473 static const char teststring[] =
"this is a test string";
478 char buffer[
sizeof(teststring) + 8];
494 ok(
read ==
sizeof(teststring) ||
495 broken(
read == ((
sizeof(teststring) + 3) & ~3)),
496 "read should be sizeof(teststring) instead of %d\n",
read);
504 ok(
buffer[0] == 0,
"buffer data should be untouched\n");
505 ok(
read == 0,
"read should be 0 instead of %d\n",
read);
507 ull.QuadPart =
sizeof(
buffer);
508 hr = IStream_SetSize(pStream, ull);
509 ok(
hr ==
E_OUTOFMEMORY,
"IStream_SetSize with invalid HGLOBAL should return E_OUTOFMEMORY instead of 0x%08x\n",
hr);
512 ok(
hr ==
E_OUTOFMEMORY,
"IStream_Write with invalid HGLOBAL should return E_OUTOFMEMORY instead of 0x%08x\n",
hr);
513 ok(written == 0,
"written should be 0 instead of %d\n", written);
515 IStream_Release(pStream);
534 ok(
stat.type == STGTY_STREAM,
"unexpected %#x\n",
stat.type);
535 ok(!
stat.pwcsName,
"unexpected %p\n",
stat.pwcsName);
537 ok(!
stat.cbSize.HighPart,
"unexpected %#x\n",
stat.cbSize.HighPart);
549 static const char hello[] =
"Hello World!";
553 HGLOBAL orig_hmem, hmem, hmem_clone;
560 ok(orig_hmem != 0,
"unexpected %p\n", orig_hmem);
571 ok(hmem == orig_hmem,
"handles should match\n");
573 ok(
pos == 0,
"unexpected %d\n",
pos);
582 ok(hmem != 0,
"unexpected %p\n", hmem);
584 ok(
pos == 13,
"unexpected %d\n",
pos);
587 ok(hmem_clone == hmem,
"handles should match\n");
589 ok(
pos == 0,
"unexpected %d\n",
pos);
597 hr = IStream_SetSize(
stream, newsize);
601 ok(hmem != 0,
"unexpected %p\n", hmem);
602 ok(hmem == orig_hmem,
"unexpected %p\n", hmem);
604 ok(
pos == 13,
"unexpected %d\n",
pos);
607 ok(hmem_clone == hmem,
"handles should match\n");
609 ok(
pos == 13,
"unexpected %d\n",
pos);
611 IStream_Release(clone);
616 ok(orig_hmem != 0,
"unexpected %p\n", orig_hmem);
624 ok(hmem != 0,
"unexpected %p\n", hmem);
626 ok(
pos == 0,
"unexpected %d\n",
pos);
629 ok(hmem_clone == hmem,
"handles should match\n");
631 ok(
pos == 0,
"unexpected %d\n",
pos);
634 hr = IStream_SetSize(
stream, newsize);
638 ok(hmem != 0,
"unexpected %p\n", hmem);
639 ok(hmem != orig_hmem,
"unexpected %p\n", hmem);
641 ok(
pos == 0,
"unexpected %d\n",
pos);
644 ok(hmem_clone == hmem,
"handles should match\n");
646 ok(
pos == 0,
"unexpected %d\n",
pos);
649 IStream_Release(clone);
653 ok(orig_hmem != 0,
"unexpected %p\n", orig_hmem);
661 ok(hmem != 0,
"unexpected %p\n", hmem);
663 ok(
pos == 0,
"unexpected %d\n",
pos);
666 ok(hmem_clone == hmem,
"handles should match\n");
668 ok(
pos == 0,
"unexpected %d\n",
pos);
671 hr = IStream_SetSize(
stream, newsize);
675 ok(hmem != 0,
"unexpected %p\n", hmem);
676 ok(hmem != orig_hmem,
"unexpected %p\n", hmem);
678 ok(
pos == 0,
"unexpected %d\n",
pos);
681 ok(hmem_clone != hmem,
"handles should not match\n");
683 ok(
pos == 0,
"unexpected %d\n",
pos);
698 ok(hmem != 0,
"unexpected %p\n", hmem);
700 ok(
pos == 0,
"unexpected %d\n",
pos);
703 ok(hmem_clone == hmem,
"handles should match\n");
705 ok(
pos == 0,
"unexpected %d\n",
pos);
708 ok(
ret == 0,
"unexpected %d\n",
ret);
711 hr = IStream_SetSize(clone, newsize);
715 ok(hmem_clone == hmem,
"handles should match\n");
717 ok(
pos == 0,
"unexpected %d\n",
pos);
723 ok(hmem_clone == hmem,
"handles should match\n");
725 ok(
pos == 13,
"unexpected %d\n",
pos);
728 hr = IStream_Seek(clone,
offset, STREAM_SEEK_SET,
NULL);
737 ok(hmem_clone == hmem,
"handles should match\n");
739 ok(
pos == 32,
"unexpected %d\n",
pos);
741 ret = IStream_Release(clone);
742 ok(
ret == 0,
"unexpected %d\n",
ret);
int strcmp(const char *String1, const char *String2)
ACPI_SIZE strlen(const char *String)
char * strcpy(char *DstString, const char *SrcString)
HRESULT WINAPI GetHGlobalFromStream(IStream *pstm, HGLOBAL *phglobal)
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
static HMODULE MODULEINFO DWORD cb
static HRESULT WINAPI TestStream_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
static HRESULT WINAPI TestStream_Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
static HRESULT WINAPI TestStream_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
static void test_IStream_Clone(void)
static HRESULT WINAPI TestStream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
static void test_copyto(void)
static HRESULT WINAPI TestStream_CopyTo(IStream *iface, IStream *pStream, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
static HRESULT WINAPI TestStream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
#define ok_ole_success(hr, func)
static HRESULT WINAPI TestStream_Revert(IStream *iface)
static char const *const * expected_method_list
static IStreamVtbl StreamVtbl
#define CHECK_EXPECTED_METHOD(method_name)
static HRESULT WINAPI TestStream_Write(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
static HRESULT WINAPI TestStream_Commit(IStream *iface, DWORD grfCommitFlags)
static void test_streamonhglobal(void)
static HRESULT WINAPI TestStream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
static void stream_info(IStream *stream, HGLOBAL *hmem, int *size, int *pos)
static ULONG WINAPI TestStream_Release(IStream *iface)
static HRESULT WINAPI TestStream_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
static HRESULT WINAPI TestStream_Clone(IStream *iface, IStream **pStream)
static ULONG WINAPI TestStream_AddRef(IStream *iface)
static void test_freed_hglobal(void)
static IStream Test_Stream
static const LARGE_INTEGER llZero
#define IsEqualIID(riid1, riid2)
static __inline const char * wine_dbgstr_guid(const GUID *id)
struct _ULARGE_INTEGER::@4136 u
DWORD WINAPI GetLastError(void)
#define STG_E_INVALIDFUNCTION