[OLEAUT32_WINETEST] Sync with Wine Staging 2.9. CORE-13362
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 3 Jun 2017 22:34:23 +0000 (22:34 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 3 Jun 2017 22:34:23 +0000 (22:34 +0000)
svn path=/trunk/; revision=74832

rostests/winetests/oleaut32/olepicture.c
rostests/winetests/oleaut32/varformat.c
rostests/winetests/oleaut32/vartest.c
rostests/winetests/oleaut32/vartype.c

index ab220a6..1b8e395 100644 (file)
@@ -102,7 +102,7 @@ static const unsigned char pngimage[285] = {
 0xe7,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
 };
 
-/* 1x1 pixel bmp */
+/* 1bpp BI_RGB 1x1 pixel bmp */
 static const unsigned char bmpimage[66] = {
 0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
@@ -111,6 +111,15 @@ static const unsigned char bmpimage[66] = {
 0x00,0x00
 };
 
+/* 8bpp BI_RLE8 1x1 pixel bmp */
+static const unsigned char bmpimage_rle8[] = {
+0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
+0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x01,0x00,
+0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
+0x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0x00,0x01,
+0x00,0x00
+};
+
 /* 2x2 pixel gif */
 static const unsigned char gif4pixel[42] = {
 0x47,0x49,0x46,0x38,0x37,0x61,0x02,0x00,0x02,0x00,0xa1,0x00,0x00,0x00,0x00,0x00,
@@ -1465,6 +1474,7 @@ START_TEST(olepicture)
     test_pic(gifimage, sizeof(gifimage));
     test_pic(jpgimage, sizeof(jpgimage));
     test_pic(bmpimage, sizeof(bmpimage));
+    test_pic(bmpimage_rle8, sizeof(bmpimage_rle8));
     test_pic(gif4pixel, sizeof(gif4pixel));
     /* FIXME: No PNG support in Windows... */
     if (0) test_pic(pngimage, sizeof(pngimage));
index b6debdf..cabab80 100644 (file)
@@ -644,6 +644,42 @@ static void test_VarFormatFromTokens(void)
     SysFreeString(bstr);
 }
 
+static void test_GetAltMonthNames(void)
+{
+    LPOLESTR *str, *str2;
+    HRESULT hr;
+
+    str = (void *)0xdeadbeef;
+    hr = GetAltMonthNames(0, &str);
+    ok(hr == S_OK, "Unexpected return value %08x\n", hr);
+    ok(str == NULL, "Got %p\n", str);
+
+    str = (void *)0xdeadbeef;
+    hr = GetAltMonthNames(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), &str);
+    ok(hr == S_OK, "Unexpected return value %08x\n", hr);
+    ok(str == NULL, "Got %p\n", str);
+
+    str = NULL;
+    hr = GetAltMonthNames(MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_EGYPT), SORT_DEFAULT), &str);
+    ok(hr == S_OK, "Unexpected return value %08x\n", hr);
+    ok(str != NULL, "Got %p\n", str);
+
+    str2 = NULL;
+    hr = GetAltMonthNames(MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_EGYPT), SORT_DEFAULT), &str2);
+    ok(hr == S_OK, "Unexpected return value %08x\n", hr);
+    ok(str2 == str, "Got %p\n", str2);
+
+    str = NULL;
+    hr = GetAltMonthNames(MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_DEFAULT), SORT_DEFAULT), &str);
+    ok(hr == S_OK, "Unexpected return value %08x\n", hr);
+    ok(str != NULL, "Got %p\n", str);
+
+    str = NULL;
+    hr = GetAltMonthNames(MAKELCID(MAKELANGID(LANG_POLISH, SUBLANG_DEFAULT), SORT_DEFAULT), &str);
+    ok(hr == S_OK, "Unexpected return value %08x\n", hr);
+    ok(str != NULL, "Got %p\n", str);
+}
+
 START_TEST(varformat)
 {
   hOleaut32 = GetModuleHandleA("oleaut32.dll");
@@ -654,4 +690,5 @@ START_TEST(varformat)
   test_VarFormat();
   test_VarWeekdayName();
   test_VarFormatFromTokens();
+  test_GetAltMonthNames();
 }
index b54e837..8d146b3 100644 (file)
@@ -101,6 +101,150 @@ static BOOL has_i8;
 #define R8_MAX DBL_MAX
 #define R8_MIN DBL_MIN
 
+#define DEFINE_EXPECT(func) \
+    static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
+
+#define SET_EXPECT(func) \
+    do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
+
+#define CHECK_EXPECT2(func) \
+    do { \
+        ok(expect_ ##func, "unexpected call " #func "\n"); \
+        called_ ## func = TRUE; \
+    }while(0)
+
+#define CHECK_EXPECT(func) \
+    do { \
+        CHECK_EXPECT2(func); \
+        expect_ ## func = FALSE; \
+    }while(0)
+
+#define CHECK_CALLED(func) \
+    do { \
+        ok(called_ ## func, "expected " #func "\n"); \
+        expect_ ## func = called_ ## func = FALSE; \
+    }while(0)
+
+DEFINE_EXPECT(dispatch_invoke);
+
+typedef struct
+{
+    IDispatch IDispatch_iface;
+    VARTYPE vt;
+    HRESULT result;
+} DummyDispatch;
+
+static inline DummyDispatch *impl_from_IDispatch(IDispatch *iface)
+{
+    return CONTAINING_RECORD(iface, DummyDispatch, IDispatch_iface);
+}
+
+static ULONG WINAPI DummyDispatch_AddRef(IDispatch *iface)
+{
+    return 2;
+}
+
+static ULONG WINAPI DummyDispatch_Release(IDispatch *iface)
+{
+    return 1;
+}
+
+static HRESULT WINAPI DummyDispatch_QueryInterface(IDispatch *iface,
+                                                   REFIID riid,
+                                                   void** ppvObject)
+{
+    *ppvObject = NULL;
+
+    if (IsEqualIID(riid, &IID_IDispatch) ||
+        IsEqualIID(riid, &IID_IUnknown))
+    {
+        *ppvObject = iface;
+        IDispatch_AddRef(iface);
+    }
+
+    return *ppvObject ? S_OK : E_NOINTERFACE;
+}
+
+static HRESULT WINAPI DummyDispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
+{
+    ok(0, "Unexpected call\n");
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI DummyDispatch_GetTypeInfo(IDispatch *iface, UINT tinfo, LCID lcid, ITypeInfo **ti)
+{
+    ok(0, "Unexpected call\n");
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI DummyDispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *names,
+    UINT cnames, LCID lcid, DISPID *dispid)
+{
+    ok(0, "Unexpected call\n");
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI DummyDispatch_Invoke(IDispatch *iface,
+                                           DISPID dispid, REFIID riid,
+                                           LCID lcid, WORD wFlags,
+                                           DISPPARAMS *params,
+                                           VARIANT *res,
+                                           EXCEPINFO *ei,
+                                           UINT *arg_err)
+{
+    DummyDispatch *This = impl_from_IDispatch(iface);
+
+    CHECK_EXPECT(dispatch_invoke);
+
+    ok(dispid == DISPID_VALUE, "got dispid %d\n", dispid);
+    ok(IsEqualIID(riid, &IID_NULL), "go riid %s\n", wine_dbgstr_guid(riid));
+    ok(wFlags == DISPATCH_PROPERTYGET, "Flags wrong\n");
+
+    ok(params->rgvarg == NULL, "got %p\n", params->rgvarg);
+    ok(params->rgdispidNamedArgs == NULL, "got %p\n", params->rgdispidNamedArgs);
+    ok(params->cArgs == 0, "got %d\n", params->cArgs);
+    ok(params->cNamedArgs == 0, "got %d\n", params->cNamedArgs);
+
+    ok(res != NULL, "got %p\n", res);
+    ok(V_VT(res) == VT_EMPTY, "got %d\n", V_VT(res));
+    ok(ei == NULL, "got %p\n", ei);
+    ok(arg_err == NULL, "got %p\n", arg_err);
+
+    if (FAILED(This->result))
+        return This->result;
+
+    V_VT(res) = This->vt;
+    if (This->vt == VT_UI1)
+        V_UI1(res) = 34;
+    else if (This->vt == VT_NULL)
+    {
+        V_VT(res) = VT_NULL;
+        V_BSTR(res) = NULL;
+    }
+    else
+        memset(res, 0, sizeof(*res));
+
+    return S_OK;
+}
+
+static const IDispatchVtbl DummyDispatch_VTable =
+{
+    DummyDispatch_QueryInterface,
+    DummyDispatch_AddRef,
+    DummyDispatch_Release,
+    DummyDispatch_GetTypeInfoCount,
+    DummyDispatch_GetTypeInfo,
+    DummyDispatch_GetIDsOfNames,
+    DummyDispatch_Invoke
+};
+
+static void init_test_dispatch(VARTYPE vt, DummyDispatch *dispatch)
+{
+    dispatch->IDispatch_iface.lpVtbl = &DummyDispatch_VTable;
+    dispatch->vt = vt;
+    dispatch->result = S_OK;
+}
+
 typedef struct IRecordInfoImpl
 {
     IRecordInfo IRecordInfo_iface;
@@ -5611,6 +5755,7 @@ static void test_VarCat(void)
     HRESULT hres;
     HRESULT expected_error_num;
     int cmp;
+    DummyDispatch dispatch;
 
     CHECKPTR(VarCat);
 
@@ -5945,6 +6090,67 @@ static void test_VarCat(void)
     VariantClear(&result);
     VariantClear(&expected);
 
+    /* Dispatch conversion */
+    init_test_dispatch(VT_NULL, &dispatch);
+    V_VT(&left) = VT_DISPATCH;
+    V_DISPATCH(&left) = &dispatch.IDispatch_iface;
+
+    SET_EXPECT(dispatch_invoke);
+    hres = VarCat(&left, &right, &result);
+    todo_wine ok(hres == S_OK, "got 0x%08x\n", hres);
+    ok(V_VT(&result) == VT_BSTR, "got %d\n", V_VT(&result));
+    ok(SysStringLen(V_BSTR(&result)) == 0, "got %d\n", SysStringLen(V_BSTR(&result)));
+    CHECK_CALLED(dispatch_invoke);
+
+    VariantClear(&left);
+    VariantClear(&right);
+    VariantClear(&result);
+
+    init_test_dispatch(VT_NULL, &dispatch);
+    V_VT(&right) = VT_DISPATCH;
+    V_DISPATCH(&right) = &dispatch.IDispatch_iface;
+
+    SET_EXPECT(dispatch_invoke);
+    hres = VarCat(&left, &right, &result);
+    todo_wine ok(hres == S_OK, "got 0x%08x\n", hres);
+    ok(V_VT(&result) == VT_BSTR, "got %d\n", V_VT(&result));
+    ok(SysStringLen(V_BSTR(&result)) == 0, "got %d\n", SysStringLen(V_BSTR(&result)));
+    CHECK_CALLED(dispatch_invoke);
+
+    VariantClear(&left);
+    VariantClear(&right);
+    VariantClear(&result);
+
+    init_test_dispatch(VT_UI1, &dispatch);
+    V_VT(&right) = VT_DISPATCH;
+    V_DISPATCH(&right) = &dispatch.IDispatch_iface;
+
+    V_VT(&left) = VT_BSTR;
+    V_BSTR(&left) = SysAllocString(sz12);
+    SET_EXPECT(dispatch_invoke);
+    hres = pVarCat(&left,&right,&result);
+    ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres);
+    CHECK_CALLED(dispatch_invoke);
+    ok(!strcmp_wa(V_BSTR(&result), "1234"), "got %s\n", wine_dbgstr_w(V_BSTR(&result)));
+
+    VariantClear(&left);
+    VariantClear(&right);
+    VariantClear(&result);
+
+    init_test_dispatch(VT_NULL, &dispatch);
+    dispatch.result = E_OUTOFMEMORY;
+    V_VT(&right) = VT_DISPATCH;
+    V_DISPATCH(&right) = &dispatch.IDispatch_iface;
+
+    SET_EXPECT(dispatch_invoke);
+    hres = VarCat(&left, &right, &result);
+    todo_wine ok(hres == E_OUTOFMEMORY, "got 0x%08x\n", hres);
+    CHECK_CALLED(dispatch_invoke);
+
+    VariantClear(&left);
+    VariantClear(&right);
+    VariantClear(&result);
+
     /* Test boolean conversion */
     V_VT(&left) = VT_BOOL;
     V_BOOL(&left) = VARIANT_TRUE;
index 9c2785a..d92ed4e 100644 (file)
@@ -3415,6 +3415,8 @@ static void test_VarDateFromStr(void)
   SYSTEMTIME st;
   OLECHAR buff[128];
   size_t i;
+  OLECHAR with_ideographic_spaceW[] = { '6','/','3','0','/','2','0','1','1',0x3000,
+                                        '1',':','2','0',':','3','4',0 };
 
   lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
 
@@ -3538,6 +3540,11 @@ static void test_VarDateFromStr(void)
   DFS("6/30/2011 01:20:34 PM");       EXPECT_DBL(40724.55594907407);
   /* Native fails "1999 January 3, 9AM". I consider that a bug in native */
 
+  /* test a data with ideographic space */
+  out = 0.0;
+  hres = pVarDateFromStr(with_ideographic_spaceW, lcid, LOCALE_NOUSEROVERRIDE, &out);
+  EXPECT_DBL(40724.05594907407);
+
   /* test a non-english data string */
   DFS("02.01.1970"); EXPECT_MISMATCH;
   DFS("02.01.1970 00:00:00"); EXPECT_MISMATCH;