push 0f15bbd80d260bbd8adf052e820484a405c49375
[wine/hacks.git] / dlls / inetcomm / tests / mimeole.c
blobc425c214c206eba7fdfbbd98dd48aac630abd316
1 /*
2 * MimeOle tests
4 * Copyright 2007 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include "windows.h"
24 #include "ole2.h"
25 #include "ocidl.h"
27 #include "initguid.h"
28 #include "mimeole.h"
30 #include <stdio.h>
31 #include <assert.h>
33 #include "wine/test.h"
35 static char msg1[] =
36 "MIME-Version: 1.0\r\n"
37 "Content-Type: multipart/mixed;\r\n"
38 " boundary=\"------------1.5.0.6\";\r\n"
39 " stuff=\"du;nno\"\r\n"
40 "foo: bar\r\n"
41 "From: Huw Davies <huw@codeweavers.com>\r\n"
42 "From: Me <xxx@codeweavers.com>\r\n"
43 "To: wine-patches <wine-patches@winehq.org>\r\n"
44 "Cc: Huw Davies <huw@codeweavers.com>,\r\n"
45 " \"Fred Bloggs\" <fred@bloggs.com>\r\n"
46 "foo: baz\r\n"
47 "bar: fum\r\n"
48 "\r\n"
49 "This is a multi-part message in MIME format.\r\n"
50 "--------------1.5.0.6\r\n"
51 "Content-Type: text/plain; format=fixed; charset=UTF-8\r\n"
52 "Content-Transfer-Encoding: 8bit\r\n"
53 "\r\n"
54 "Stuff\r\n"
55 "--------------1.5.0.6\r\n"
56 "Content-Type: text/plain; charset=\"us-ascii\"\r\n"
57 "Content-Transfer-Encoding: 7bit\r\n"
58 "\r\n"
59 "More stuff\r\n"
60 "--------------1.5.0.6--\r\n";
62 static void test_CreateVirtualStream(void)
64 HRESULT hr;
65 IStream *pstm;
67 hr = MimeOleCreateVirtualStream(&pstm);
68 ok(hr == S_OK, "ret %08x\n", hr);
70 IStream_Release(pstm);
73 static void test_CreateSecurity(void)
75 HRESULT hr;
76 IMimeSecurity *sec;
78 hr = MimeOleCreateSecurity(&sec);
79 ok(hr == S_OK, "ret %08x\n", hr);
81 IMimeSecurity_Release(sec);
84 static void test_CreateBody(void)
86 HRESULT hr;
87 IMimeBody *body;
88 HBODY handle = (void *)0xdeadbeef;
89 IStream *in;
90 LARGE_INTEGER off;
91 ULARGE_INTEGER pos;
92 ENCODINGTYPE enc;
94 hr = CoCreateInstance(&CLSID_IMimeBody, NULL, CLSCTX_INPROC_SERVER, &IID_IMimeBody, (void**)&body);
95 ok(hr == S_OK, "ret %08x\n", hr);
97 hr = IMimeBody_GetHandle(body, &handle);
98 ok(hr == MIME_E_NO_DATA, "ret %08x\n", hr);
99 ok(handle == NULL, "handle %p\n", handle);
101 hr = CreateStreamOnHGlobal(NULL, TRUE, &in);
102 ok(hr == S_OK, "ret %08x\n", hr);
103 IStream_Write(in, msg1, sizeof(msg1) - 1, NULL);
104 off.QuadPart = 0;
105 IStream_Seek(in, off, STREAM_SEEK_SET, NULL);
107 /* Need to call InitNew before Load otherwise Load crashes with native inetcomm */
108 hr = IMimeBody_InitNew(body);
109 ok(hr == S_OK, "ret %08x\n", hr);
111 hr = IMimeBody_GetCurrentEncoding(body, &enc);
112 ok(hr == S_OK, "ret %08x\n", hr);
113 ok(enc == IET_7BIT, "encoding %d\n", enc);
115 hr = IMimeBody_Load(body, in);
116 ok(hr == S_OK, "ret %08x\n", hr);
117 off.QuadPart = 0;
118 IStream_Seek(in, off, STREAM_SEEK_CUR, &pos);
119 ok(pos.LowPart == 328, "pos %u\n", pos.LowPart);
121 hr = IMimeBody_IsContentType(body, "multipart", "mixed");
122 ok(hr == S_OK, "ret %08x\n", hr);
123 hr = IMimeBody_IsContentType(body, "text", "plain");
124 ok(hr == S_FALSE, "ret %08x\n", hr);
125 hr = IMimeBody_IsContentType(body, NULL, "mixed");
126 ok(hr == S_OK, "ret %08x\n", hr);
128 hr = IMimeBody_SetData(body, IET_8BIT, "text", "plain", &IID_IStream, in);
129 ok(hr == S_OK, "ret %08x\n", hr);
130 hr = IMimeBody_IsContentType(body, "text", "plain");
131 todo_wine
132 ok(hr == S_OK, "ret %08x\n", hr);
133 hr = IMimeBody_GetCurrentEncoding(body, &enc);
134 ok(hr == S_OK, "ret %08x\n", hr);
135 ok(enc == IET_8BIT, "encoding %d\n", enc);
137 IMimeBody_Release(body);
140 START_TEST(mimeole)
142 OleInitialize(NULL);
143 test_CreateVirtualStream();
144 test_CreateSecurity();
145 test_CreateBody();
146 OleUninitialize();