[OLE32_WINETEST]
[reactos.git] / rostests / winetests / ole32 / hglobalstream.c
index 0810d9f..27ad542 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
 #define COBJMACROS
 
 #include <stdarg.h>
 
-#include "windef.h"
-#include "winbase.h"
-#include "objbase.h"
+#include <windef.h>
+#include <winbase.h>
+#include <ole2.h>
+//#include "objbase.h"
 
-#include "wine/test.h"
+#include <wine/test.h>
 
 #define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
 
@@ -175,7 +180,7 @@ static void test_streamonhglobal(IStream *pStream)
     ull.u.HighPart = 0xCAFECAFE;
     ull.u.LowPart = 0xCAFECAFE;
     ll.u.HighPart = 0;
-    ll.u.LowPart = -sizeof(data);
+    ll.u.LowPart = -(DWORD)sizeof(data);
     hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
     ok_ole_success(hr, "IStream_Seek");
     ok(ull.u.LowPart == 0, "LowPart set to %d\n", ull.u.LowPart);
@@ -190,7 +195,7 @@ static void test_streamonhglobal(IStream *pStream)
     ull.u.HighPart = 0xCAFECAFE;
     ull.u.LowPart = 0xCAFECAFE;
     ll.u.HighPart = 0;
-    ll.u.LowPart = -sizeof(data)-1;
+    ll.u.LowPart = -(DWORD)sizeof(data)-1;
     hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
     ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr);
     ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart);
@@ -261,14 +266,17 @@ static void test_streamonhglobal(IStream *pStream)
     ok(ull.u.LowPart == 0x80000008, "should have set LowPart to 0x80000008 instead of %08x\n", ull.u.LowPart);
     ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
 
-    /* IStream_Seek -- seek wraps position/size on integer overflow */
+    /* IStream_Seek -- seek wraps position/size on integer overflow, but not on win8 */
     ull.u.HighPart = 0xCAFECAFE;
     ull.u.LowPart = 0xCAFECAFE;
     ll.u.HighPart = 0;
     ll.u.LowPart = 0x7FFFFFFF;
     hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
-    ok_ole_success(hr, "IStream_Seek");
-    ok(ull.u.LowPart == 0x00000007, "should have set LowPart to 0x00000007 instead of %08x\n", ull.u.LowPart);
+    ok(hr == S_OK || hr == STG_E_SEEKERROR /* win8 */, "IStream_Seek\n");
+    if (SUCCEEDED(hr))
+        ok(ull.u.LowPart == 0x00000007, "should have set LowPart to 0x00000007 instead of %08x\n", ull.u.LowPart);
+    else
+        ok(ull.u.LowPart == 0x80000008, "should have set LowPart to 0x80000008 instead of %08x\n", ull.u.LowPart);
     ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
 
     hr = IStream_Commit(pStream, STGC_DEFAULT);
@@ -299,7 +307,7 @@ static HRESULT WINAPI TestStream_QueryInterface(IStream *iface, REFIID riid, voi
         IsEqualIID(riid, &IID_IStream))
     {
         *ppv = iface;
-        IUnknown_AddRef(iface);
+        IStream_AddRef(iface);
         return S_OK;
     }
     *ppv = NULL;
@@ -421,6 +429,8 @@ static void test_copyto(void)
     static const LARGE_INTEGER llZero;
     char buffer[15];
 
+    ok_ole_success(hr, "CreateStreamOnHGlobal");
+
     expected_method_list = methods_copyto;
 
     hr = IStream_Write(pStream, szHello, sizeof(szHello), &written);