[OLE32_WINETEST] Sync with Wine Staging 3.3. CORE-14434
authorAmine Khaldi <amine.khaldi@reactos.org>
Tue, 20 Mar 2018 11:38:58 +0000 (12:38 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Tue, 20 Mar 2018 11:38:58 +0000 (12:38 +0100)
15 files changed:
modules/rostests/winetests/ole32/clipboard.c
modules/rostests/winetests/ole32/compobj.c
modules/rostests/winetests/ole32/defaulthandler.c
modules/rostests/winetests/ole32/dragdrop.c
modules/rostests/winetests/ole32/errorinfo.c
modules/rostests/winetests/ole32/hglobalstream.c
modules/rostests/winetests/ole32/marshal.c
modules/rostests/winetests/ole32/moniker.c
modules/rostests/winetests/ole32/ole2.c
modules/rostests/winetests/ole32/ole_server.c
modules/rostests/winetests/ole32/precomp.h
modules/rostests/winetests/ole32/propvariant.c
modules/rostests/winetests/ole32/stg_prop.c
modules/rostests/winetests/ole32/storage32.c
modules/rostests/winetests/ole32/usrmarshal.c

index 64fafaf..002312d 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#define COBJMACROS
+#define CONST_VTABLE
+#ifndef __REACTOS__
+#define NONAMELESSUNION
+#endif
 
-#include "precomp.h"
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+
+#include "wine/test.h"
 
 #define InitFormatEtc(fe, cf, med) \
         {\
index eeb4686..06d1914 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "precomp.h"
+#define COBJMACROS
+#define CONST_VTABLE
 
-#include <dde.h>
-#include <ctxtcall.h>
-#include <initguid.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "windef.h"
+#include "winbase.h"
+#define USE_COM_CONTEXT_DEF
+#ifndef __REACTOS__
+#include "initguid.h"
+#endif
+#include "objbase.h"
+#include "shlguid.h"
+#include "urlmon.h" /* for CLSID_FileProtocol */
+#include "dde.h"
+#include "cguid.h"
 
-extern const IID GUID_NULL;
+#include "ctxtcall.h"
+
+#include "wine/test.h"
+
+#ifdef __REACTOS__
+#include <initguid.h>
+#endif
 
 #define DEFINE_EXPECT(func) \
     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
@@ -926,6 +944,7 @@ static DWORD WINAPI MessageFilter_MessagePending(
   DWORD dwPendingType)
 {
     trace("MessagePending\n");
+    todo_wine ok(0, "unexpected call\n");
     return PENDINGMSG_WAITNOPROCESS;
 }
 
@@ -2620,6 +2639,15 @@ static DWORD CALLBACK send_message_thread(LPVOID arg)
     return 0;
 }
 
+static DWORD CALLBACK send_and_post_user_message_thread(void *arg)
+{
+    HWND hwnd = arg;
+    Sleep(30);
+    SendMessageA(hwnd, WM_USER, 0, 0);
+    PostMessageA(hwnd, WM_USER, 0, 0);
+    return 0;
+}
+
 static DWORD CALLBACK post_message_thread(LPVOID arg)
 {
     HWND hWnd = arg;
@@ -2629,14 +2657,103 @@ static DWORD CALLBACK post_message_thread(LPVOID arg)
 }
 
 static const char cls_name[] = "cowait_test_class";
+
+static UINT cowait_msgs[100], cowait_msgs_first, cowait_msgs_last;
+
+static void cowait_msgs_reset(void)
+{
+    cowait_msgs_first = cowait_msgs_last = 0;
+}
+
+#define cowait_msgs_expect_empty() _cowait_msgs_expect_empty(__LINE__)
+static void _cowait_msgs_expect_empty(unsigned line)
+{
+    while(cowait_msgs_first < cowait_msgs_last) {
+        ok_(__FILE__,line)(0, "unexpected message %u\n", cowait_msgs[cowait_msgs_first]);
+        cowait_msgs_first++;
+    }
+    cowait_msgs_reset();
+}
+
+#define cowait_msgs_expect_notified(a) _cowait_msgs_expect_notified(__LINE__,a)
+static void _cowait_msgs_expect_notified(unsigned line, UINT expected_msg)
+{
+    if(cowait_msgs_first == cowait_msgs_last) {
+        ok_(__FILE__,line)(0, "expected message %u, received none\n", expected_msg);
+    }else {
+        ok_(__FILE__,line)(cowait_msgs[cowait_msgs_first] == expected_msg,
+                           "expected message %u, received %u \n",
+                           expected_msg, cowait_msgs[cowait_msgs_first]);
+        cowait_msgs_first++;
+    }
+}
+
+#define cowait_msgs_expect_queued(a,b) _cowait_msgs_expect_queued(__LINE__,a,b)
+static void _cowait_msgs_expect_queued(unsigned line, HWND hwnd, UINT expected_msg)
+{
+    MSG msg;
+    BOOL success;
+
+    success = PeekMessageA(&msg, hwnd, expected_msg, expected_msg, PM_REMOVE);
+    ok_(__FILE__,line)(success, "PeekMessageA failed: %u\n", GetLastError());
+    if(success)
+        ok_(__FILE__,line)(msg.message == expected_msg, "unexpected message %u, expected %u\n",
+                           msg.message, expected_msg);
+}
+
+static void flush_messages(void)
+{
+    MSG msg;
+    while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ));
+}
+
+static LRESULT CALLBACK cowait_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+    if(cowait_msgs_last < sizeof(cowait_msgs)/sizeof(*cowait_msgs))
+        cowait_msgs[cowait_msgs_last++] = msg;
+    if(msg == WM_DDE_FIRST)
+        return 6;
+    return DefWindowProcA(hwnd, msg, wparam, lparam);
+}
+
+static DWORD CALLBACK cowait_unmarshal_thread(void *arg)
+{
+    IStream *stream = arg;
+    IEnumOLEVERB *enum_verb;
+    LARGE_INTEGER zero;
+    IUnknown *unk;
+    HRESULT hr;
+
+    CoInitialize(NULL);
+
+    zero.QuadPart = 0;
+    hr = IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
+    ok(hr == S_OK, "Seek failed: %08x\n", hr);
+
+    hr = CoUnmarshalInterface(stream, &IID_IUnknown, (void**)&unk);
+    ok(hr == S_OK, "CoUnmarshalInterface failed: %08x\n", hr);
+
+    hr = IUnknown_QueryInterface(unk, &IID_IEnumOLEVERB, (void**)&enum_verb);
+    ok(hr == S_OK, "QueryInterface failed: %08x\n", hr);
+
+    IEnumOLEVERB_Release(enum_verb);
+    IUnknown_Release(unk);
+
+    CoUninitialize();
+    return 0;
+}
+
 static DWORD CALLBACK test_CoWaitForMultipleHandles_thread(LPVOID arg)
 {
-    HANDLE *handles = arg;
+    HANDLE *handles = arg, event, thread;
+    IStream *stream;
     BOOL success;
-    DWORD index;
+    DWORD index, tid;
     HRESULT hr;
     HWND hWnd;
+    UINT uMSG = 0xc065;
     MSG msg;
+    int ret;
 
     hr = pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
     ok(hr == S_OK, "CoInitializeEx failed with error 0x%08x\n", hr);
@@ -2660,8 +2777,58 @@ static DWORD CALLBACK test_CoWaitForMultipleHandles_thread(LPVOID arg)
     success = PeekMessageA(&msg, hWnd, WM_USER, WM_USER, PM_REMOVE);
     ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n");
 
+    /* Even if CoWaitForMultipleHandles does not pump a message it peeks
+     * at ALL of them */
+    index = 0xdeadbeef;
+    PostMessageA(NULL, uMSG, 0, 0);
+
+    hr = CoWaitForMultipleHandles(COWAIT_ALERTABLE, 50, 2, handles, &index);
+    ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
+    ok(index == 0 || broken(index == 0xdeadbeef) /* Win 8 */, "expected index 0, got %u\n", index);
+
+    /* Make sure message was peeked at */
+    ret = MsgWaitForMultipleObjectsEx(0, NULL, 2, QS_ALLPOSTMESSAGE, MWMO_ALERTABLE);
+    ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
+
+    /* But not pumped */
+    success = PeekMessageA(&msg, NULL, uMSG, uMSG, PM_REMOVE);
+    ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n");
+
     DestroyWindow(hWnd);
     CoUninitialize();
+
+    hr = pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+    ok(hr == S_OK, "CoInitializeEx failed with error 0x%08x\n", hr);
+
+    hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
+    ok(hr == S_OK, "CreateStreamOnHGlobal failed: %08x\n", hr);
+
+    hr = CoMarshalInterface(stream, &IID_IUnknown, &Test_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
+    ok(hr == S_OK, "CoMarshalInterface should have returned S_OK instead of 0x%08x\n", hr);
+
+    event = CreateEventW(NULL, TRUE, FALSE, NULL);
+
+    PostQuitMessage(66);
+    PostThreadMessageW(GetCurrentThreadId(), WM_QUIT, 0, 0);
+
+    hr = CoRegisterMessageFilter(&MessageFilter, NULL);
+    ok(hr == S_OK, "CoRegisterMessageFilter failed: %08x\n", hr);
+
+    thread = CreateThread(NULL, 0, cowait_unmarshal_thread, stream, 0, &tid);
+    ok(thread != NULL, "CreateThread failed, error %u\n", GetLastError());
+    hr = CoWaitForMultipleHandles(0, 50, 1, &event, &index);
+    ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
+    index = WaitForSingleObject(thread, 200);
+    ok(index == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
+    CloseHandle(thread);
+
+    hr = CoRegisterMessageFilter(NULL, NULL);
+    ok(hr == S_OK, "CoRegisterMessageFilter failed: %08x\n", hr);
+
+    IStream_Release(stream);
+
+    CloseHandle(event);
+    CoUninitialize();
     return 0;
 }
 
@@ -2685,7 +2852,7 @@ static void test_CoWaitForMultipleHandles(void)
     wc.hCursor       = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
     wc.hbrBackground = NULL;
     wc.lpszClassName = cls_name;
-    wc.lpfnWndProc   = DefWindowProcA;
+    wc.lpfnWndProc   = cowait_window_proc;
     success = RegisterClassExA(&wc) != 0;
     ok(success, "RegisterClassExA failed %u\n", GetLastError());
 
@@ -2860,6 +3027,29 @@ static void test_CoWaitForMultipleHandles(void)
     ok(index == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
     CloseHandle(thread);
 
+    cowait_msgs_reset();
+    PostMessageA(hWnd, 0, 0, 0);
+    PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
+    PostMessageA(hWnd, WM_USER+1, 0, 0);
+    PostMessageA(hWnd, WM_DDE_FIRST+1, 0, 0);
+    thread = CreateThread(NULL, 0, send_and_post_user_message_thread, hWnd, 0, &tid);
+    ok(thread != NULL, "CreateThread failed, error %u\n", GetLastError());
+
+    hr = CoWaitForMultipleHandles(0, 100, 2, handles, &index);
+    ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
+
+    cowait_msgs_expect_notified(WM_DDE_FIRST);
+    cowait_msgs_expect_notified(WM_DDE_FIRST+1);
+    cowait_msgs_expect_notified(WM_USER);
+    cowait_msgs_expect_empty();
+    cowait_msgs_expect_queued(hWnd, WM_USER);
+    cowait_msgs_expect_queued(hWnd, WM_USER+1);
+    flush_messages();
+
+    index = WaitForSingleObject(thread, 200);
+    ok(index == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
+    CloseHandle(thread);
+
     /* test behaviour of WM_QUIT (semaphores are still locked) */
 
     PostMessageA(hWnd, WM_QUIT, 40, 0);
@@ -2871,6 +3061,29 @@ static void test_CoWaitForMultipleHandles(void)
     success = PeekMessageA(&msg, hWnd, WM_QUIT, WM_QUIT, PM_REMOVE);
     ok(!success, "PeekMessageA succeeded\n");
 
+    cowait_msgs_reset();
+    PostMessageA(hWnd, WM_QUIT, 40, 0);
+    PostMessageA(hWnd, 0, 0, 0);
+    PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
+    PostMessageA(hWnd, WM_USER+1, 0, 0);
+    PostMessageA(hWnd, WM_DDE_FIRST+1, 0, 0);
+    thread = CreateThread(NULL, 0, send_and_post_user_message_thread, hWnd, 0, &tid);
+    ok(thread != NULL, "CreateThread failed, error %u\n", GetLastError());
+
+    hr = CoWaitForMultipleHandles(0, 100, 2, handles, &index);
+    ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
+
+    cowait_msgs_expect_notified(WM_DDE_FIRST);
+    cowait_msgs_expect_notified(WM_DDE_FIRST+1);
+    cowait_msgs_expect_notified(WM_USER);
+    cowait_msgs_expect_empty();
+    cowait_msgs_expect_queued(hWnd, WM_USER);
+    flush_messages();
+
+    index = WaitForSingleObject(thread, 200);
+    ok(index == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
+    CloseHandle(thread);
+
     index = 0xdeadbeef;
     PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
     PostMessageA(hWnd, WM_QUIT, 41, 0);
@@ -2940,10 +3153,8 @@ static void test_CoWaitForMultipleHandles(void)
         success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
         ok(success, "PeekMessageA failed, error %u\n", GetLastError());
         success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
-        todo_wine
         ok(!success, "PeekMessageA succeeded\n");
         success = PeekMessageA(&msg, hWnd, WM_QUIT, WM_QUIT, PM_REMOVE);
-        todo_wine
         ok(!success, "CoWaitForMultipleHandles didn't remove WM_QUIT messages\n");
         index = WaitForSingleObject(thread, 200);
         ok(index == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
@@ -2960,7 +3171,6 @@ static void test_CoWaitForMultipleHandles(void)
         success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
         ok(success, "PeekMessageA failed, error %u\n", GetLastError());
         success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
-        todo_wine
         ok(!success, "PeekMessageA succeeded\n");
         success = PeekMessageA(&msg, hWnd, WM_QUIT, WM_QUIT, PM_REMOVE);
         ok(!success, "CoWaitForMultipleHandles didn't remove WM_QUIT messages\n");
index c9e6af9..60bc29c 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "precomp.h"
+#define COBJMACROS
+#define CONST_VTABLE
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+
+#include "wine/test.h"
 
 #define DEFINE_EXPECT(func) \
     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
index e14e757..6abe4a9 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "precomp.h"
+#define _WIN32_DCOM
+#define COBJMACROS
+#define CONST_VTABLE
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+
+#include "wine/test.h"
+
 
 #define METHOD_LIST \
     METHOD(DO_EnumFormatEtc), \
index c3e99a7..bb350ae 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "precomp.h"
+#define COBJMACROS
+#define CONST_VTABLE
+
+#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%08x\n", hr)
 
index 9974cd3..15bf7c2 100644 (file)
@@ -2,6 +2,7 @@
  * Stream on HGLOBAL Tests
  *
  * Copyright 2006 Robert Shearman (for CodeWeavers)
+ * Copyright 2016 Dmitry Timoshkov
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "precomp.h"
+#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%08x\n", hr)
 
@@ -35,16 +44,20 @@ do { \
         } \
 } while(0)
 
-static void test_streamonhglobal(IStream *pStream)
+static void test_streamonhglobal(void)
 {
     const char data[] = "Test String";
     ULARGE_INTEGER ull;
+    IStream *pStream;
     LARGE_INTEGER ll;
     char buffer[128];
     ULONG read;
     STATSTG statstg;
     HRESULT hr;
 
+    hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
+    ok(hr == S_OK, "Failed to create a stream, hr %#x.\n", hr);
+
     ull.QuadPart = sizeof(data);
     hr = IStream_SetSize(pStream, ull);
     ok_ole_success(hr, "IStream_SetSize");
@@ -285,6 +298,8 @@ static void test_streamonhglobal(IStream *pStream)
     hr = IStream_SetSize(pStream, ull);
     ok(hr == E_OUTOFMEMORY || broken(hr == S_OK), /* win9x */
        "IStream_SetSize with large size should have returned E_OUTOFMEMORY instead of 0x%08x\n", hr);
+
+    IStream_Release(pStream);
 }
 
 static HRESULT WINAPI TestStream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
@@ -500,16 +515,237 @@ static void test_freed_hglobal(void)
     IStream_Release(pStream);
 }
 
-START_TEST(hglobalstream)
+static void stream_info(IStream *stream, HGLOBAL *hmem, int *size, int *pos)
 {
     HRESULT hr;
-    IStream *pStream;
+    STATSTG stat;
+    LARGE_INTEGER offset;
+    ULARGE_INTEGER newpos;
+
+    *hmem = 0;
+    *size = *pos = -1;
+
+    hr = GetHGlobalFromStream(stream, hmem);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    memset(&stat, 0x55, sizeof(stat));
+    hr = IStream_Stat(stream, &stat, STATFLAG_DEFAULT);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+    ok(stat.type == STGTY_STREAM, "unexpected %#x\n", stat.type);
+    ok(!stat.pwcsName, "unexpected %p\n", stat.pwcsName);
+    ok(IsEqualIID(&stat.clsid, &GUID_NULL), "unexpected %s\n", wine_dbgstr_guid(&stat.clsid));
+    ok(!stat.cbSize.HighPart, "unexpected %#x\n", stat.cbSize.HighPart);
+    *size = stat.cbSize.LowPart;
+
+    offset.QuadPart = 0;
+    hr = IStream_Seek(stream, offset, STREAM_SEEK_CUR, &newpos);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+    ok(!newpos.HighPart, "unexpected %#x\n", newpos.HighPart);
+    *pos = newpos.LowPart;
+}
 
-    hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
-    ok_ole_success(hr, "CreateStreamOnHGlobal");
+static void test_IStream_Clone(void)
+{
+    static const char hello[] = "Hello World!";
+    char buf[32];
+    HRESULT hr;
+    IStream *stream, *clone;
+    HGLOBAL orig_hmem, hmem, hmem_clone;
+    ULARGE_INTEGER newsize;
+    LARGE_INTEGER offset;
+    int size, pos, ret;
+
+    /* test simple case for Clone */
+    orig_hmem = GlobalAlloc(GMEM_MOVEABLE, 0);
+    ok(orig_hmem != 0, "unexpected %p\n", orig_hmem);
+    hr = CreateStreamOnHGlobal(orig_hmem, TRUE, &stream);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    hr = GetHGlobalFromStream(stream, NULL);
+    ok(hr == E_INVALIDARG, "unexpected %#x\n", hr);
+
+    hr = GetHGlobalFromStream(NULL, &hmem);
+    ok(hr == E_INVALIDARG, "unexpected %#x\n", hr);
+
+    stream_info(stream, &hmem, &size, &pos);
+    ok(hmem == orig_hmem, "handles should match\n");
+    ok(size == 0,  "unexpected %d\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    hr = IStream_Clone(stream, &clone);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    hr = IStream_Write(stream, hello, sizeof(hello), NULL);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    stream_info(stream, &hmem, &size, &pos);
+    ok(hmem != 0, "unexpected %p\n", hmem);
+    ok(size == 13,  "unexpected %d\n", size);
+    ok(pos == 13,  "unexpected %d\n", pos);
+
+    stream_info(clone, &hmem_clone, &size, &pos);
+    ok(hmem_clone == hmem, "handles should match\n");
+    ok(size == 13,  "unexpected %d\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    buf[0] = 0;
+    hr = IStream_Read(clone, buf, sizeof(buf), NULL);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+    ok(!strcmp(buf, hello), "wrong stream contents\n");
+
+    newsize.QuadPart = 0x8000;
+    hr = IStream_SetSize(stream, newsize);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    stream_info(stream, &hmem, &size, &pos);
+    ok(hmem != 0,  "unexpected %p\n", hmem);
+    ok(hmem == orig_hmem,  "unexpected %p\n", hmem);
+    ok(size == 0x8000,  "unexpected %#x\n", size);
+    ok(pos == 13,  "unexpected %d\n", pos);
+
+    stream_info(clone, &hmem_clone, &size, &pos);
+    ok(hmem_clone == hmem, "handles should match\n");
+    ok(size == 0x8000,  "unexpected %#x\n", size);
+    ok(pos == 13,  "unexpected %d\n", pos);
+
+    IStream_Release(clone);
+    IStream_Release(stream);
+
+    /* exploit GMEM_FIXED forced move for the same base streams */
+    orig_hmem = GlobalAlloc(GMEM_FIXED, 1);
+    ok(orig_hmem != 0, "unexpected %p\n", orig_hmem);
+    hr = CreateStreamOnHGlobal(orig_hmem, TRUE, &stream);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    hr = IStream_Clone(stream, &clone);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    stream_info(stream, &hmem, &size, &pos);
+    ok(hmem != 0,  "unexpected %p\n", hmem);
+    ok(size == 1,  "unexpected %d\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    stream_info(clone, &hmem_clone, &size, &pos);
+    ok(hmem_clone == hmem, "handles should match\n");
+    ok(size == 1,  "unexpected %d\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    newsize.QuadPart = 0x8000;
+    hr = IStream_SetSize(stream, newsize);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    stream_info(stream, &hmem, &size, &pos);
+    ok(hmem != 0,  "unexpected %p\n", hmem);
+    ok(hmem != orig_hmem,  "unexpected %p\n", hmem);
+    ok(size == 0x8000,  "unexpected %#x\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    stream_info(clone, &hmem_clone, &size, &pos);
+    ok(hmem_clone == hmem, "handles should match\n");
+    ok(size == 0x8000,  "unexpected %#x\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    IStream_Release(stream);
+    IStream_Release(clone);
+
+    /* exploit GMEM_FIXED forced move for different base streams */
+    orig_hmem = GlobalAlloc(GMEM_FIXED, 1);
+    ok(orig_hmem != 0, "unexpected %p\n", orig_hmem);
+    hr = CreateStreamOnHGlobal(orig_hmem, TRUE, &stream);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    hr = CreateStreamOnHGlobal(orig_hmem, TRUE, &clone);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    stream_info(stream, &hmem, &size, &pos);
+    ok(hmem != 0,  "unexpected %p\n", hmem);
+    ok(size == 1,  "unexpected %d\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    stream_info(clone, &hmem_clone, &size, &pos);
+    ok(hmem_clone == hmem, "handles should match\n");
+    ok(size == 1,  "unexpected %d\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    newsize.QuadPart = 0x8000;
+    hr = IStream_SetSize(stream, newsize);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    stream_info(stream, &hmem, &size, &pos);
+    ok(hmem != 0,  "unexpected %p\n", hmem);
+    ok(hmem != orig_hmem,  "unexpected %p\n", hmem);
+    ok(size == 0x8000,  "unexpected %#x\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    stream_info(clone, &hmem_clone, &size, &pos);
+    ok(hmem_clone != hmem, "handles should not match\n");
+    ok(size == 1,  "unexpected %#x\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    IStream_Release(stream);
+    /* releasing clone leads to test termination under windows
+    IStream_Release(clone);
+    */
+
+    /* test Release for a being cloned stream */
+    hr = CreateStreamOnHGlobal(0, TRUE, &stream);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    hr = IStream_Clone(stream, &clone);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    stream_info(stream, &hmem, &size, &pos);
+    ok(hmem != 0,  "unexpected %p\n", hmem);
+    ok(size == 0,  "unexpected %d\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    stream_info(clone, &hmem_clone, &size, &pos);
+    ok(hmem_clone == hmem, "handles should match\n");
+    ok(size == 0,  "unexpected %#x\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    ret = IStream_Release(stream);
+    ok(ret == 0, "unexpected %d\n", ret);
+
+    newsize.QuadPart = 0x8000;
+    hr = IStream_SetSize(clone, newsize);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    stream_info(clone, &hmem_clone, &size, &pos);
+    ok(hmem_clone == hmem, "handles should match\n");
+    ok(size == 0x8000,  "unexpected %#x\n", size);
+    ok(pos == 0,  "unexpected %d\n", pos);
+
+    hr = IStream_Write(clone, hello, sizeof(hello), NULL);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    stream_info(clone, &hmem_clone, &size, &pos);
+    ok(hmem_clone == hmem, "handles should match\n");
+    ok(size == 0x8000,  "unexpected %#x\n", size);
+    ok(pos == 13,  "unexpected %d\n", pos);
+
+    offset.QuadPart = 0;
+    hr = IStream_Seek(clone, offset, STREAM_SEEK_SET, NULL);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+
+    buf[0] = 0;
+    hr = IStream_Read(clone, buf, sizeof(buf), NULL);
+    ok(hr == S_OK, "unexpected %#x\n", hr);
+    ok(!strcmp(buf, hello), "wrong stream contents\n");
+
+    stream_info(clone, &hmem_clone, &size, &pos);
+    ok(hmem_clone == hmem, "handles should match\n");
+    ok(size == 0x8000,  "unexpected %#x\n", size);
+    ok(pos == 32,  "unexpected %d\n", pos);
+
+    ret = IStream_Release(clone);
+    ok(ret == 0, "unexpected %d\n", ret);
+}
 
-    test_streamonhglobal(pStream);
-    IStream_Release(pStream);
+START_TEST(hglobalstream)
+{
+    test_streamonhglobal();
     test_copyto();
     test_freed_hglobal();
+    test_IStream_Clone();
 }
index 2a29e66..12c46e9 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "precomp.h"
-
-#include <shlguid.h>
+#define _WIN32_DCOM
+#define COBJMACROS
+#define CONST_VTABLE
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+#include "olectl.h"
+#include "shlguid.h"
+#include "shobjidl.h"
+#include "initguid.h"
+
+#include "wine/test.h"
 
 DEFINE_GUID(CLSID_StdGlobalInterfaceTable,0x00000323,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
 DEFINE_GUID(CLSID_ManualResetEvent,       0x0000032c,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
index ca94904..7b67dfd 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "precomp.h"
-
-#include <comcat.h>
-#include <olectl.h>
+#define _WIN32_DCOM
+#define COBJMACROS
+#define CONST_VTABLE
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+#include "ocidl.h"
+#include "initguid.h"
+#include "comcat.h"
+#include "olectl.h"
+
+#include "wine/test.h"
 
 #define ok_more_than_one_lock() ok(cLocks > 0, "Number of locks should be > 0, but actually is %d\n", cLocks)
 #define ok_no_locks() ok(cLocks == 0, "Number of locks should be 0, but actually is %d\n", cLocks)
index d6dafc0..231f9d2 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "precomp.h"
+#define COBJMACROS
+#define CONST_VTABLE
+#define WIN32_LEAN_AND_MEAN
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "objbase.h"
+#include "shlguid.h"
+
+#include "wine/test.h"
 
-#ifndef __REACTOS__
 #include "initguid.h"
 
 DEFINE_GUID(CLSID_Picture_Metafile,0x315,0,0,0xc0,0,0,0,0,0,0,0x46);
 DEFINE_GUID(CLSID_Picture_Dib,0x316,0,0,0xc0,0,0,0,0,0,0,0x46);
 DEFINE_GUID(CLSID_Picture_EnhMetafile,0x319,0,0,0xc0,0,0,0,0,0,0,0x46);
-#endif
 
 #define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
 
@@ -144,7 +154,11 @@ typedef struct PresentationDataHeader
     DWORD dwSize;
 } PresentationDataHeader;
 
+#ifdef __REACTOS__
 static inline void check_expected_method_fmt(const char *method_name, const FORMATETC *fmt)
+#else
+static void inline check_expected_method_fmt(const char *method_name, const FORMATETC *fmt)
+#endif
 {
     trace("%s\n", method_name);
     ok(expected_method_list->method != NULL, "Extra method %s called\n", method_name);
@@ -2416,6 +2430,40 @@ static void test_data_cache_cache(void)
 
     IDataObject_Release( data );
     IOleCache2_Release( cache );
+
+    /* tests for a static class cache */
+    hr = CreateDataCache( NULL, &CLSID_Picture_Dib, &IID_IOleCache2, (void **)&cache );
+
+    fmt.cfFormat = CF_DIB;
+    fmt.dwAspect = DVASPECT_CONTENT;
+    fmt.tymed = TYMED_HGLOBAL;
+    hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
+    ok( hr == CACHE_S_SAMECACHE, "got %08x\n", hr );
+
+    /* aspect other than DVASPECT_CONTENT should fail */
+    fmt.dwAspect = DVASPECT_THUMBNAIL;
+    hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
+    ok( FAILED(hr), "got %08x\n", hr );
+
+    fmt.dwAspect = DVASPECT_DOCPRINT;
+    hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
+    ok( FAILED(hr), "got %08x\n", hr );
+
+    /* try caching another clip format */
+    fmt.cfFormat = CF_METAFILEPICT;
+    fmt.dwAspect = DVASPECT_CONTENT;
+    fmt.tymed = TYMED_MFPICT;
+    hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
+    ok( FAILED(hr), "got %08x\n", hr );
+
+    /* As an exception, it's possible to add an icon aspect */
+    fmt.cfFormat = CF_METAFILEPICT;
+    fmt.dwAspect = DVASPECT_ICON;
+    fmt.tymed = TYMED_MFPICT;
+    hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    IOleCache2_Release( cache );
 }
 
 /* The CLSID_Picture_ classes automatically create appropriate cache entries */
@@ -3976,13 +4024,18 @@ static void check_storage_contents(IStorage *stg, const struct storage_def *stg_
         hr = IStorage_OpenStream(stg, stat.pwcsName, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
         ok(hr == S_OK, "unexpected %#x\n", hr);
 
-        if (!memcmp(name, "\2OlePres", 7))
+        if (!memcmp(name, "\2OlePres", 8))
         {
+            ULONG header_size = sizeof(header);
+
             clipformat = read_clipformat(stream);
 
-            hr = IStream_Read(stream, &header, sizeof(header), &bytes);
+            if (clipformat == 0) /* view cache */
+                header_size = FIELD_OFFSET(PresentationDataHeader, unknown7);
+
+            hr = IStream_Read(stream, &header, header_size, &bytes);
             ok(hr == S_OK, "unexpected %#x\n", hr);
-            ok(bytes >= 24, "read %u bytes\n", bytes);
+            ok(bytes == header_size, "read %u bytes, expected %u\n", bytes, header_size);
 
             if (winetest_debug > 1)
                 trace("header: tdSize %#x, dvAspect %#x, lindex %#x, advf %#x, unknown7 %#x, dwObjectExtentX %#x, dwObjectExtentY %#x, dwSize %#x\n",
@@ -4218,12 +4271,14 @@ static void test_data_cache_save_data(void)
                 { CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
                 { CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },
                 { CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF },
+                { 0, 0, DVASPECT_DOCPRINT, -1, TYMED_HGLOBAL },
             },
-            3, 3, &CLSID_WineTest,
+            4, 3, &CLSID_WineTest,
             {
-                &CLSID_WineTestOld, 3, { { "\2OlePres000", CF_DIB, DVASPECT_CONTENT, 0, NULL, 0 },
+                &CLSID_WineTestOld, 4, { { "\2OlePres000", CF_DIB, DVASPECT_CONTENT, 0, NULL, 0 },
                                          { "\2OlePres001", CF_METAFILEPICT, DVASPECT_CONTENT, 0, NULL, 0 },
-                                         { "\2OlePres002", CF_ENHMETAFILE, DVASPECT_CONTENT, 0, NULL, 0 } }
+                                         { "\2OlePres002", CF_ENHMETAFILE, DVASPECT_CONTENT, 0, NULL, 0 },
+                                         { "\2OlePres003", 0, DVASPECT_DOCPRINT, 0, NULL, 0 } }
             }
         },
         /* without setting data */
@@ -4410,7 +4465,6 @@ static void test_data_cache_contents(void)
         ok(hr == S_OK, "unexpected %#x\n", hr);
 
         hr = IPersistStorage_IsDirty(stg);
-todo_wine_if(test_data[i].in == &stg_def_4 || test_data[i].in == &stg_def_8 || test_data[i].in == &stg_def_9)
         ok(hr == S_FALSE, "%d: unexpected %#x\n", i, hr);
 
         hr = IPersistStorage_Save(stg, doc2, FALSE);
@@ -4423,7 +4477,8 @@ todo_wine_if(test_data[i].in == &stg_def_4 || test_data[i].in == &stg_def_8 || t
 todo_wine_if(!(test_data[i].in == &stg_def_0 || test_data[i].in == &stg_def_1 || test_data[i].in == &stg_def_2))
         ok(enumerated_streams == matched_streams, "%d out: enumerated %d != matched %d\n", i,
            enumerated_streams, matched_streams);
-todo_wine_if(!(test_data[i].in == &stg_def_0 || test_data[i].in == &stg_def_5))
+todo_wine_if(!(test_data[i].in == &stg_def_0 || test_data[i].in == &stg_def_4 || test_data[i].in == &stg_def_5
+                 || test_data[i].in == &stg_def_6))
         ok(enumerated_streams == test_data[i].out->stream_count, "%d: saved streams %d != def streams %d\n", i,
             enumerated_streams, test_data[i].out->stream_count);
 
index 9ca8bdf..77abda4 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "precomp.h"
+#define COBJMACROS
+#define CONST_VTABLE
+
+#include <windows.h>
+#include <exdisp.h>
+#include <tlhelp32.h>
+#include <stdio.h>
+#include <assert.h>
+#include "wine/test.h"
 
 #include <initguid.h>
 DEFINE_GUID(CLSID_WineTestObject, 0xdeadbeef,0xdead,0xbeef,0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef);
index 24b5295..86f0481 100644 (file)
@@ -1,3 +1,4 @@
+
 #ifndef _OLE32_WINETEST_PRECOMP_H_
 #define _OLE32_WINETEST_PRECOMP_H_
 
index 8c32566..ade45fb 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "precomp.h"
+#include "windows.h"
+#include "wtypes.h"
+#include "ddeml.h"
 
-#include <ddeml.h>
+#include "wine/test.h"
 
 /* invalid in all versions */
 #define PROP_INV 0x7f
index 9b189c6..c6d7d3e 100644 (file)
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
-
-#include "precomp.h"
+#include <stdio.h>
+#define COBJMACROS
+#include "objbase.h"
+#include "wine/test.h"
+#include "initguid.h"
 
 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
 DEFINE_GUID(FMTID_SummaryInformation,0xF29F85E0,0x4FF9,0x1068,0xAB,0x91,0x08,0x00,0x2B,0x27,0xB3,0xD9);
index 756b769..89ffc95 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "precomp.h"
+#include <stdio.h>
 
-#include <initguid.h>
+#define COBJMACROS
+#ifndef __REACTOS__
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+#endif
+
+#include <windows.h>
+#include "wine/test.h"
+
+#include "ole2.h"
+#include "objidl.h"
+#include "initguid.h"
 
 DEFINE_GUID( test_stg_cls, 0x88888888, 0x0425, 0x0000, 0,0,0,0,0,0,0,0);
 
index 8576ed7..3919395 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "precomp.h"
+#define COBJMACROS
+#define CONST_VTABLE
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+#include "objidl.h"
+
+#include "wine/test.h"
 
 ULONG __RPC_USER HMETAFILE_UserSize(ULONG *, ULONG, HMETAFILE *);
 unsigned char * __RPC_USER HMETAFILE_UserMarshal(ULONG *, unsigned char *, HMETAFILE *);