[PATCH 2/6] OLE: Bug in IPersistStream::Save.
Nathan Beckmann
nathan.beckmann at gmail.com
Sun Feb 24 09:57:15 CST 2008
Found bug in IPersistStream::Save. Added tests that demonstrate
incorrect behavior.
---
dlls/oleaut32/tests/Makefile.in | 2 +-
dlls/oleaut32/tests/olepicture.c | 79 ++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 1 deletions(-)
diff --git a/dlls/oleaut32/tests/Makefile.in b/dlls/oleaut32/tests/Makefile.in
index 49b8706..fdd1b50 100644
--- a/dlls/oleaut32/tests/Makefile.in
+++ b/dlls/oleaut32/tests/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = oleaut32.dll
-IMPORTS = oleaut32 ole32 rpcrt4 user32 gdi32 advapi32 kernel32
+IMPORTS = shlwapi oleaut32 ole32 rpcrt4 user32 gdi32 advapi32 kernel32
EXTRALIBS = -luuid -luser32
CTESTS = \
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
index 6e732c1..e1b9aca 100644
--- a/dlls/oleaut32/tests/olepicture.c
+++ b/dlls/oleaut32/tests/olepicture.c
@@ -36,6 +36,9 @@
#include <winerror.h>
#include <winnt.h>
+#include <winreg.h>
+#include <shlwapi.h>
+
#include <wtypes.h>
#include <olectl.h>
#include <objidl.h>
@@ -480,6 +483,80 @@ static void test_apm()
IStream_Release(stream);
}
+static void test_save_picture()
+{
+ HRESULT ret;
+ LPSTREAM in_stream;
+ LPSTREAM out_stream;
+ IPicture *pic;
+ IPersistStream *persist_stream;
+ ULONG dummy;
+ int i;
+ int image_differ;
+ unsigned char output_file[sizeof(bmpimage)+4];
+
+ static const char oleloadpicture_file[] = { 't','e','s','t','.','b','m','p','\0' };
+ static const char ipersiststream_save_file[] = { 't','e','s','t','_','i','p','e','r','s','i','s','t','s','t','r','e','a','m','.','b','m','p','\0' };
+
+ in_stream = NULL;
+ out_stream = NULL;
+ pic = NULL;
+ persist_stream = NULL;
+
+ /* Create file */
+ ret = SHCreateStreamOnFileA(oleloadpicture_file, STGM_SHARE_DENY_WRITE | STGM_WRITE | STGM_CREATE, &out_stream);
+ ok(ret == S_OK, "Failed to create test image.\n");
+ if (FAILED(ret)) return;
+ IStream_Write(out_stream, bmpimage, sizeof(bmpimage), &dummy);
+ IStream_Release(out_stream);
+
+ /* OleLoadPicture */
+ ret = SHCreateStreamOnFileA(oleloadpicture_file, STGM_SHARE_DENY_WRITE | STGM_READ | STGM_FAILIFTHERE, &in_stream);
+ ok(ret == S_OK, "Failed to create stream on %s.\n", oleloadpicture_file);
+ ok(in_stream != NULL, "in_stream should point to a valid stream object.\n");
+ if (in_stream == NULL) return;
+
+ ret = OleLoadPicture(in_stream, 0, TRUE, &IID_IPicture, (LPVOID*) &pic);
+ ok(ret == S_OK, "Failed to load %s.\n", oleloadpicture_file);
+
+ IStream_Release(in_stream);
+
+ /* IPersistStream */
+ ret = IPicture_QueryInterface(pic, &IID_IPersistStream, (LPVOID*) &persist_stream);
+ ok(ret == S_OK, "Couldn't query IPersistStream from pic.\n");
+
+ ret = SHCreateStreamOnFileA(ipersiststream_save_file, STGM_SHARE_DENY_WRITE | STGM_WRITE | STGM_CREATE, &out_stream);
+ ok(ret == S_OK, "Failed to create stream on %s.\n", ipersiststream_save_file);
+
+ ret = IPersistStream_Save(persist_stream, out_stream, FALSE);
+ ok(ret == S_OK, "Failed to IPersistStream::Save");
+
+ IStream_Release(out_stream);
+ IPersistStream_Release(persist_stream);
+
+ IPicture_Release(pic);
+
+ /* Test output */
+ ret = SHCreateStreamOnFileA(ipersiststream_save_file, STGM_SHARE_DENY_WRITE | STGM_READ | STGM_FAILIFTHERE, &in_stream);
+ ok(ret == S_OK, "Failed to read IPersistStream::Save test image.\n");
+ if (SUCCEEDED(ret)) {
+ IStream_Read(in_stream, output_file, sizeof(output_file), &dummy);
+ todo_wine {
+ ok(dummy == sizeof(bmpimage), "Output from IPersistStream::Save is different size than test image.\n");
+ }
+ image_differ = FALSE;
+ for (i = 0; i < sizeof(bmpimage); i++) {
+ if (output_file[i] != bmpimage[i])
+ image_differ = TRUE;
+ }
+ todo_wine {
+ ok(!image_differ, "Output from IPersistStream::Save differs from test image.\n");
+ }
+
+ IStream_Release(in_stream);
+ }
+}
+
START_TEST(olepicture)
{
hOleaut32 = GetModuleHandleA("oleaut32.dll");
@@ -502,6 +579,8 @@ START_TEST(olepicture)
test_empty_image_2();
test_apm();
+ test_save_picture();
+
test_Invoke();
test_OleCreatePictureIndirect();
}
--
1.5.4.2
More information about the wine-patches
mailing list