Robert Shearman : ole32:
Add tests for the stream object returned by CreateStreamOnHGlobal.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Sep 11 06:05:09 CDT 2006
Module: wine
Branch: master
Commit: e10103e3ec9497dcb60fb5c5f0ae2499b1399de9
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=e10103e3ec9497dcb60fb5c5f0ae2499b1399de9
Author: Robert Shearman <rob at codeweavers.com>
Date: Mon Sep 11 11:11:19 2006 +0100
ole32: Add tests for the stream object returned by CreateStreamOnHGlobal.
---
dlls/ole32/tests/Makefile.in | 1
dlls/ole32/tests/hglobalstream.c | 102 ++++++++++++++++++++++++++++++++++++++
2 files changed, 103 insertions(+), 0 deletions(-)
create mode 100644 dlls/ole32/tests/hglobalstream.c
diff --git a/dlls/ole32/tests/Makefile.in b/dlls/ole32/tests/Makefile.in
index 27d43a0..9d7068c 100644
--- a/dlls/ole32/tests/Makefile.in
+++ b/dlls/ole32/tests/Makefile.in
@@ -9,6 +9,7 @@ EXTRALIBS = -luuid
CTESTS = \
clipboard.c \
compobj.c \
+ hglobalstream.c \
marshal.c \
moniker.c \
ole2.c \
diff --git a/dlls/ole32/tests/hglobalstream.c b/dlls/ole32/tests/hglobalstream.c
new file mode 100644
index 0000000..f335852
--- /dev/null
+++ b/dlls/ole32/tests/hglobalstream.c
@@ -0,0 +1,102 @@
+/*
+ * Stream on HGLOBAL Tests
+ *
+ * Copyright 2006 Robert Shearman (for CodeWeavers)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+
+#include "wine/test.h"
+
+#define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08lx\n", hr)
+
+static void test_streamonhglobal(IStream *pStream)
+{
+ const char data[] = "Test String";
+ ULARGE_INTEGER ull;
+ LARGE_INTEGER ll;
+ char buffer[128];
+ ULONG read;
+ STATSTG statstg;
+ HRESULT hr;
+
+ ull.QuadPart = sizeof(data);
+ hr = IStream_SetSize(pStream, ull);
+ ok_ole_success(hr, "IStream_SetSize");
+
+ hr = IStream_Write(pStream, data, sizeof(data), NULL);
+ ok_ole_success(hr, "IStream_Write");
+
+ ll.QuadPart = 0;
+ hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, NULL);
+ ok_ole_success(hr, "IStream_Seek");
+
+ /* should return S_OK, not S_FALSE */
+ hr = IStream_Read(pStream, buffer, sizeof(buffer), &read);
+ todo_wine {
+ ok_ole_success(hr, "IStream_Read");
+ }
+ ok(read == sizeof(data), "IStream_Read returned read %ld instead of %d\n", read, sizeof(data));
+
+ /* ignores HighPart */
+ ull.HighPart = -1;
+ ull.LowPart = 0;
+ hr = IStream_SetSize(pStream, ull);
+ todo_wine {
+ ok_ole_success(hr, "IStream_SetSize");
+ }
+
+ hr = IStream_Commit(pStream, STGC_DEFAULT);
+ ok_ole_success(hr, "IStream_Commit");
+
+ hr = IStream_Revert(pStream);
+ ok_ole_success(hr, "IStream_Revert");
+
+ hr = IStream_LockRegion(pStream, ull, ull, LOCK_WRITE);
+ todo_wine {
+ ok(hr == STG_E_INVALIDFUNCTION, "IStream_LockRegion should have returned STG_E_INVALIDFUNCTION instead of 0x%08lx\n", hr);
+ }
+
+ hr = IStream_Stat(pStream, &statstg, STATFLAG_DEFAULT);
+ ok_ole_success(hr, "IStream_Stat");
+ ok(statstg.type == STGTY_STREAM, "statstg.type should have been STGTY_STREAM instead of %ld\n", statstg.type);
+
+ /* test OOM condition */
+ ull.HighPart = -1;
+ ull.LowPart = -1;
+ hr = IStream_SetSize(pStream, ull);
+ todo_wine {
+ ok(hr == E_OUTOFMEMORY, "IStream_SetSize with large size should have returned E_OUTOFMEMORY instead of 0x%08lx\n", hr);
+ }
+}
+
+START_TEST(hglobalstream)
+{
+ HRESULT hr;
+ IStream *pStream;
+
+ hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
+ ok_ole_success(hr, "CreateStreamOnHGlobal");
+
+ test_streamonhglobal(pStream);
+}
More information about the wine-cvs
mailing list