Module: wine Branch: master Commit: c99b874a68a3ab9a6c767ae1993c633a99718713 URL: http://source.winehq.org/git/wine.git/?a=commit;h=c99b874a68a3ab9a6c767ae199...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Jan 27 15:59:43 2017 +0100
inetcomm/tests: Added a helper for creating stream from string.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/inetcomm/tests/mimeole.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c index 924e0e3..7e510c5 100644 --- a/dlls/inetcomm/tests/mimeole.c +++ b/dlls/inetcomm/tests/mimeole.c @@ -82,6 +82,25 @@ static void test_CreateSecurity(void) IMimeSecurity_Release(sec); }
+static IStream *create_stream_from_string(const char *data) +{ + LARGE_INTEGER off; + IStream *stream; + HRESULT hr; + + hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); + ok(hr == S_OK, "ret %08x\n", hr); + + hr = IStream_Write(stream, data, strlen(data), NULL); + ok(hr == S_OK, "Write failed: %08x\n", hr); + + off.QuadPart = 0; + hr = IStream_Seek(stream, off, STREAM_SEEK_SET, NULL); + ok(hr == S_OK, "Seek failed: %08x\n", hr); + + return stream; +} + static void test_CreateBody(void) { HRESULT hr; @@ -103,11 +122,7 @@ static void test_CreateBody(void) ok(hr == MIME_E_NO_DATA, "ret %08x\n", hr); ok(handle == NULL, "handle %p\n", handle);
- hr = CreateStreamOnHGlobal(NULL, TRUE, &in); - ok(hr == S_OK, "ret %08x\n", hr); - IStream_Write(in, msg1, sizeof(msg1) - 1, NULL); - off.QuadPart = 0; - IStream_Seek(in, off, STREAM_SEEK_SET, NULL); + in = create_stream_from_string(msg1);
/* Need to call InitNew before Load otherwise Load crashes with native inetcomm */ hr = IMimeBody_InitNew(body); @@ -212,7 +227,6 @@ static void test_CreateMessage(void) HRESULT hr; IMimeMessage *msg; IStream *stream; - LARGE_INTEGER pos; LONG ref; HBODY hbody, hbody2; IMimeBody *body; @@ -230,10 +244,7 @@ static void test_CreateMessage(void) hr = MimeOleCreateMessage(NULL, &msg); ok(hr == S_OK, "ret %08x\n", hr);
- CreateStreamOnHGlobal(NULL, TRUE, &stream); - IStream_Write(stream, msg1, sizeof(msg1) - 1, NULL); - pos.QuadPart = 0; - IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL); + stream = create_stream_from_string(msg1);
hr = IMimeMessage_Load(msg, stream); ok(hr == S_OK, "ret %08x\n", hr);