[OLEAUT32_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409
authorAmine Khaldi <amine.khaldi@reactos.org>
Thu, 17 Nov 2016 22:59:30 +0000 (22:59 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Thu, 17 Nov 2016 22:59:30 +0000 (22:59 +0000)
svn path=/trunk/; revision=73286

rostests/winetests/oleaut32/olefont.c
rostests/winetests/oleaut32/olepicture.c
rostests/winetests/oleaut32/safearray.c
rostests/winetests/oleaut32/typelib.c
rostests/winetests/oleaut32/vartest.c

index 31bab2c..5cf4987 100644 (file)
@@ -1235,6 +1235,7 @@ static void test_realization(void)
 static void test_OleCreateFontIndirect(void)
 {
     FONTDESC fontdesc;
+    IUnknown *unk, *unk2;
     IFont *font;
     HRESULT hr;
 
@@ -1266,6 +1267,20 @@ static void test_OleCreateFontIndirect(void)
     hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font);
     EXPECT_HR(hr, S_OK);
     IFont_Release(font);
+
+    hr = OleInitialize(NULL);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    hr = CoGetClassObject(&CLSID_StdFont, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)&unk);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void**)&unk2);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    IUnknown_Release(unk);
+    IUnknown_Release(unk2);
+
+    OleUninitialize();
 }
 
 START_TEST(olefont)
index f24ed4e..b934fd7 100644 (file)
@@ -173,6 +173,25 @@ static const unsigned char enhmetafile[] = {
     0x14, 0x00, 0x00, 0x00
 };
 
+static HBITMAP stock_bm;
+
+static HDC create_render_dc( void )
+{
+    HDC dc = CreateCompatibleDC( NULL );
+    BITMAPINFO info = {{sizeof(info.bmiHeader), 100, 100, 1, 32, BI_RGB }};
+    void *bits;
+    HBITMAP dib = CreateDIBSection( NULL, &info, DIB_RGB_COLORS, &bits, NULL, 0 );
+
+    stock_bm = SelectObject( dc, dib );
+    return dc;
+}
+
+static void delete_render_dc( HDC dc )
+{
+    HBITMAP dib = SelectObject( dc, stock_bm );
+    DeleteObject( dib );
+    DeleteDC( dc );
+}
 
 typedef struct NoStatStreamImpl
 {
@@ -484,7 +503,7 @@ static void test_Invoke(void)
     ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08x\n", hr);
 
     /* DISPID_PICT_RENDER */
-    hdc = GetDC(0);
+    hdc = create_render_dc();
 
     for (i = 0; i < sizeof(args)/sizeof(args[0]); i++)
         V_VT(&args[i]) = VT_I4;
@@ -520,7 +539,7 @@ static void test_Invoke(void)
     hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_RENDER, &GUID_NULL, 0, DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL);
     ok(hr == DISP_E_BADPARAMCOUNT, "got 0x%08x\n", hr);
 
-    ReleaseDC(NULL, hdc);
+    delete_render_dc(hdc);
     IPictureDisp_Release(picdisp);
 }
 
@@ -704,7 +723,7 @@ static void test_Render(void)
     OLE_XSIZE_HIMETRIC pWidth;
     OLE_YSIZE_HIMETRIC pHeight;
     COLORREF result, expected;
-    HDC hdc = GetDC(0);
+    HDC hdc = create_render_dc();
 
     /* test IPicture::Render return code on uninitialized picture */
     OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (VOID**)&pic);
@@ -736,7 +755,7 @@ static void test_Render(void)
     desc.u.icon.hicon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION);
     if(!desc.u.icon.hicon){
         win_skip("LoadIcon failed. Skipping...\n");
-        ReleaseDC(NULL, hdc);
+        delete_render_dc(hdc);
         return;
     }
 
@@ -769,27 +788,22 @@ static void test_Render(void)
     hres = picture_render(pic, hdc, 1, 1, 9, 9, 0, 0, pWidth, -pHeight, NULL);
     ole_expect(hres, S_OK);
 
-    if(hres != S_OK) {
-        IPicture_Release(pic);
-        ReleaseDC(NULL, hdc);
-        return;
-    }
+    if(hres != S_OK) goto done;
 
     /* Evaluate the rendered Icon */
     result = GetPixel(hdc, 0, 0);
     ok(result == expected,
        "Color at 0,0 should be unchanged 0x%06X, but was 0x%06X\n", expected, result);
     result = GetPixel(hdc, 5, 5);
-    ok(result != expected ||
-        broken(result == expected), /* WinNT 4.0 and older may claim they drew */
-                                    /* the icon, even if they didn't. */
+    ok(result != expected,
        "Color at 5,5 should have changed, but still was 0x%06X\n", expected);
     result = GetPixel(hdc, 10, 10);
     ok(result == expected,
        "Color at 10,10 should be unchanged 0x%06X, but was 0x%06X\n", expected, result);
 
+done:
     IPicture_Release(pic);
-    ReleaseDC(NULL, hdc);
+    delete_render_dc(hdc);
 }
 
 static void test_get_Attributes(void)
index e2cd8c0..a73829d 100644 (file)
@@ -710,11 +710,9 @@ static void test_safearray(void)
     }
 
     if (!pSafeArrayAllocDescriptorEx)
-    {
         return;
-    }
 
-       for (i=0;i<sizeof(vttypes)/sizeof(vttypes[0]);i++) {
+    for (i = 0; i < sizeof(vttypes)/sizeof(vttypes[0]); i++) {
                a = NULL;
                hres = pSafeArrayAllocDescriptorEx(vttypes[i].vt,1,&a);
                ok(hres == S_OK, "SafeArrayAllocDescriptorEx gave hres 0x%x\n", hres);
@@ -768,7 +766,7 @@ static void test_safearray(void)
                }
                hres = SafeArrayDestroyDescriptor(a);
                ok(hres == S_OK,"SADD failed with hres %x\n",hres);
-       }
+    }
 }
 
 static void test_SafeArrayAllocDestroyDescriptor(void)
index 03a5ef8..a40f3db 100644 (file)
@@ -229,15 +229,13 @@ static void ref_count_test(LPCWSTR type_lib)
 
 static void test_TypeComp(void)
 {
+    ITypeComp *pTypeComp, *tcomp, *pTypeComp_tmp;
+    ITypeInfo *pTypeInfo, *ti, *pFontTypeInfo;
     ITypeLib *pTypeLib;
-    ITypeComp *pTypeComp;
     HRESULT hr;
     ULONG ulHash;
     DESCKIND desckind;
     BINDPTR bindptr;
-    ITypeInfo *pTypeInfo;
-    ITypeInfo *pFontTypeInfo;
-    ITypeComp *pTypeComp_tmp;
     static WCHAR wszStdFunctions[] = {'S','t','d','F','u','n','c','t','i','o','n','s',0};
     static WCHAR wszSavePicture[] = {'S','a','v','e','P','i','c','t','u','r','e',0};
     static WCHAR wszOLE_TRISTATE[] = {'O','L','E','_','T','R','I','S','T','A','T','E',0};
@@ -438,6 +436,17 @@ static void test_TypeComp(void)
     hr = ITypeInfo_GetTypeComp(pFontTypeInfo, &pTypeComp);
     ok_ole_success(hr, ITypeLib_GetTypeComp);
 
+    hr = ITypeInfo_QueryInterface(pFontTypeInfo, &IID_ITypeComp, (void**)&tcomp);
+    ok(hr == S_OK, "got %08x\n", hr);
+    ok(tcomp == pTypeComp, "got %p, was %p\n", tcomp, pTypeComp);
+
+    hr = ITypeComp_QueryInterface(tcomp, &IID_ITypeInfo, (void**)&ti);
+    ok(hr == S_OK, "got %08x\n", hr);
+    ok(ti == pFontTypeInfo, "got %p, was %p\n", ti, pFontTypeInfo);
+    ITypeInfo_Release(ti);
+
+    ITypeComp_Release(tcomp);
+
     ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszClone);
     hr = ITypeComp_Bind(pTypeComp, wszClone, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
     ok_ole_success(hr, ITypeComp_Bind);
@@ -1686,7 +1695,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
     ITypeInfo *interface1, *interface2, *dual, *unknown, *dispatch, *ti;
     ITypeInfo *tinfos[2];
     ITypeInfo2 *ti2;
-    ITypeComp *tcomp;
+    ITypeComp *tcomp, *tcomp2;
     MEMBERID memids[2];
     FUNCDESC funcdesc, *pfuncdesc;
     ELEMDESC elemdesc[5], *edesc;
@@ -2026,6 +2035,8 @@ static void test_CreateTypeLib(SYSKIND sys) {
     funcdesc.lprgelemdescParam = NULL;
     funcdesc.invkind = INVOKE_FUNC;
     funcdesc.cParams = 0;
+    funcdesc.cScodes = 1;
+    funcdesc.lprgscode = NULL;
     hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
     ok(hres == S_OK, "got %08x\n", hres);
 
@@ -3601,6 +3612,11 @@ static void test_CreateTypeLib(SYSKIND sys) {
     hres = ITypeInfo_GetTypeComp(ti, &tcomp);
     ok(hres == S_OK, "got %08x\n", hres);
 
+    hres = ITypeInfo_QueryInterface(ti, &IID_ITypeComp, (void**)&tcomp2);
+    ok(hres == S_OK, "got %08x\n", hres);
+    ok(tcomp == tcomp2, "got %p, was %p\n", tcomp2, tcomp);
+    ITypeComp_Release(tcomp2);
+
     hres = ITypeComp_Bind(tcomp, invokeW, 0, INVOKE_FUNC, &interface1, &desckind, &bindptr);
     ok(hres == S_OK, "got %08x\n", hres);
     ok(desckind == DESCKIND_FUNCDESC, "got wrong desckind: 0x%x\n", desckind);
index 5cc5cd1..b54e837 100644 (file)
@@ -727,12 +727,13 @@ static void test_VariantClear(void)
 
   /* DISPATCH */
   V_VT(&v) = VT_DISPATCH;
-  V_DISPATCH(&v) = (IDispatch*)&test_myVariantClearImpl;
+  V_DISPATCH(&v) = (IDispatch*)&test_myVariantClearImpl.IUnknown_iface;
   test_myVariantClearImpl.events = 0;
   hres = VariantClear(&v);
   ok(hres == S_OK, "ret %08x\n", hres);
   ok(V_VT(&v) == 0, "vt %04x\n", V_VT(&v));
-  ok(V_DISPATCH(&v) == (IDispatch*)&test_myVariantClearImpl, "dispatch %p\n", V_DISPATCH(&v));
+  ok(V_DISPATCH(&v) == (IDispatch*)&test_myVariantClearImpl.IUnknown_iface,
+     "dispatch %p\n", V_DISPATCH(&v));
   /* Check that Release got called, but nothing else */
   ok(test_myVariantClearImpl.events ==  0x4, "Unexpected call. events %08x\n", test_myVariantClearImpl.events);