[ATL_WINETEST]
authorRafal Harabien <rafalh@reactos.org>
Thu, 15 Mar 2012 20:15:43 +0000 (20:15 +0000)
committerRafal Harabien <rafalh@reactos.org>
Thu, 15 Mar 2012 20:15:43 +0000 (20:15 +0000)
- Sync to Wine 1.3.37

svn path=/trunk/; revision=56158

rostests/winetests/atl/CMakeLists.txt
rostests/winetests/atl/atl_ax.c
rostests/winetests/atl/module.c
rostests/winetests/atl/registrar.c [new file with mode: 0644]
rostests/winetests/atl/testlist.c

index 2bf8a12..7671533 100644 (file)
@@ -4,6 +4,7 @@ add_definitions(-D_DLL -D__USE_CRTIMP)
 list(APPEND SOURCE
     atl_ax.c
     module.c
+    registrar.c
     testlist.c)
 
 add_executable(atl_winetest ${SOURCE})
@@ -11,5 +12,5 @@ add_executable(atl_winetest ${SOURCE})
 target_link_libraries(atl_winetest wine uuid)
 
 set_module_type(atl_winetest win32cui)
-add_importlibs(atl_winetest ole32 user32 atl msvcrt kernel32 ntdll)
+add_importlibs(atl_winetest ole32 user32 atl msvcrt kernel32 ntdll advapi32)
 add_cd_file(TARGET atl_winetest DESTINATION reactos/bin FOR all)
index 8b9966c..4555bd6 100644 (file)
 #include <ocidl.h>
 #include <exdisp.h>
 
-HRESULT WINAPI AtlAxAttachControl(IUnknown *, HWND, IUnknown **);
+static HRESULT (WINAPI *pAtlAxAttachControl)(IUnknown *, HWND, IUnknown **);
+
+static void init_function_pointers(void)
+{
+    HMODULE hatl = GetModuleHandleA("atl.dll");
+
+    pAtlAxAttachControl = (void *)GetProcAddress(hatl, "AtlAxAttachControl");
+}
 
 static ATOM register_class(void)
 {
@@ -64,16 +71,16 @@ static void test_AtlAxAttachControl(void)
     HRESULT hr;
     IUnknown *pObj, *pContainer;
 
-    hr = AtlAxAttachControl(NULL, NULL, NULL);
+    hr = pAtlAxAttachControl(NULL, NULL, NULL);
     ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
 
     pContainer = (IUnknown *)0xdeadbeef;
-    hr = AtlAxAttachControl(NULL, NULL, &pContainer);
+    hr = pAtlAxAttachControl(NULL, NULL, &pContainer);
     ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
     ok(pContainer == (IUnknown *)0xdeadbeef,
        "Expected the output container pointer to be untouched, got %p\n", pContainer);
 
-    hr = AtlAxAttachControl(NULL, hwnd, NULL);
+    hr = pAtlAxAttachControl(NULL, hwnd, NULL);
     ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
 
     hr = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
@@ -86,13 +93,11 @@ static void test_AtlAxAttachControl(void)
         return;
     }
 
-    hr = AtlAxAttachControl(pObj, NULL, NULL);
-    todo_wine
+    hr = pAtlAxAttachControl(pObj, NULL, NULL);
     ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
 
     pContainer = (IUnknown *)0xdeadbeef;
-    hr = AtlAxAttachControl(pObj, NULL, &pContainer);
-    todo_wine
+    hr = pAtlAxAttachControl(pObj, NULL, &pContainer);
     ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
     ok(pContainer != (IUnknown *)0xdeadbeef &&
        pContainer != NULL,
@@ -101,7 +106,7 @@ static void test_AtlAxAttachControl(void)
     if (pContainer != (IUnknown *)0xdeadbeef && pContainer != NULL)
         IUnknown_Release(pContainer);
 
-    hr = AtlAxAttachControl(pObj, hwnd, NULL);
+    hr = pAtlAxAttachControl(pObj, hwnd, NULL);
     ok(hr == S_OK, "Expected AtlAxAttachControl to return S_OK, got 0x%08x\n", hr);
 
     IUnknown_Release(pObj);
@@ -111,12 +116,17 @@ static void test_AtlAxAttachControl(void)
 
 START_TEST(atl_ax)
 {
+    init_function_pointers();
+
     if (!register_class())
         return;
 
     CoInitialize(NULL);
 
-    test_AtlAxAttachControl();
+    if (pAtlAxAttachControl)
+        test_AtlAxAttachControl();
+    else
+        win_skip("AtlAxAttachControl is not available\n");
 
     CoUninitialize();
 }
index 294d87b..2a97ef9 100644 (file)
@@ -32,7 +32,6 @@
 #include <winnls.h>
 #include <winerror.h>
 #include <winnt.h>
-#include <initguid.h>
 #include <wtypes.h>
 #include <olectl.h>
 #include <ocidl.h>
@@ -92,10 +91,14 @@ static void test_StructSize(void)
                        ok (hres == S_OK, "AtlModuleInit with %d failed (0x%x).\n", i, (int)hres);
                        break;
                default:
-                       ok (FAILED(hres), "AtlModuleInit with %d succeeded? (0x%x).\n", i, (int)hres);
+                       ok (FAILED(hres) ||
+                            broken((i > FIELD_OFFSET( struct _ATL_MODULEW, dwAtlBuildVer )) && (hres == S_OK)), /* Win95 */
+                            "AtlModuleInit with %d succeeded? (0x%x).\n", i, (int)hres);
                        break;
                }
        }
+
+        HeapFree (GetProcessHeap(), 0, tst);
 }
 
 START_TEST(module)
diff --git a/rostests/winetests/atl/registrar.c b/rostests/winetests/atl/registrar.c
new file mode 100644 (file)
index 0000000..9c5dd23
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * ATL test program
+ *
+ * Copyright 2010 Damjan Jovanovic
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * 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 <stdarg.h>
+#include <stdio.h>
+
+#define COBJMACROS
+
+#include <wine/test.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winuser.h>
+#include <wingdi.h>
+#include <winnls.h>
+#include <winerror.h>
+#include <winnt.h>
+#include <wtypes.h>
+#include <olectl.h>
+#include <ocidl.h>
+#include <initguid.h>
+#include <atliface.h>
+
+static const char textA[] =
+"HKCR \n"
+"{ \n"
+"    ForceRemove eebf73c4-50fd-478f-bbcf-db212221227a \n"
+"    { \n"
+"        val 'string' = s 'string' \n"
+"        val 'dword_quoted_dec' = d '1' \n"
+"        val 'dword_unquoted_dec' = d 1 \n"
+"        val 'dword_quoted_hex' = d '0xA' \n"
+"        val 'dword_unquoted_hex' = d 0xA \n"
+"        val 'binary_quoted' = b 'deadbeef' \n"
+"        val 'binary_unquoted' = b deadbeef \n"
+"    } \n"
+"}";
+
+static void test_registrar(void)
+{
+    IRegistrar *registrar = NULL;
+    HRESULT hr;
+    INT count;
+    WCHAR *textW = NULL;
+
+    if (!GetProcAddress(GetModuleHandleA("atl.dll"), "AtlAxAttachControl"))
+    {
+        win_skip("Old versions of atl.dll don't support binary values\n");
+        return;
+    }
+
+    hr = CoCreateInstance(&CLSID_Registrar, NULL, CLSCTX_INPROC_SERVER, &IID_IRegistrar, (void**)&registrar);
+    if (FAILED(hr))
+    {
+        skip("creating IRegistrar failed, hr = 0x%08X\n", hr);
+        return;
+    }
+
+    count = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
+    textW = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
+    if (textW)
+    {
+        DWORD dword;
+        DWORD size;
+        LONG lret;
+        HKEY key;
+        BYTE bytes[4];
+
+        MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, count);
+        hr = IRegistrar_StringRegister(registrar, textW);
+        ok(SUCCEEDED(hr), "IRegistrar_StringRegister failed, hr = 0x%08X\n", hr);
+
+        lret = RegOpenKeyA(HKEY_CLASSES_ROOT, "eebf73c4-50fd-478f-bbcf-db212221227a", &key);
+        ok(lret == ERROR_SUCCESS, "error %d opening registry key\n", lret);
+
+        size = sizeof(dword);
+        lret = RegQueryValueExA(key, "dword_unquoted_hex", NULL, NULL, (BYTE*)&dword, &size);
+        ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %d\n", lret);
+        ok(dword != 0xA, "unquoted hex is not supposed to be preserved\n");
+
+        size = sizeof(dword);
+        lret = RegQueryValueExA(key, "dword_quoted_hex", NULL, NULL, (BYTE*)&dword, &size);
+        ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %d\n", lret);
+        ok(dword != 0xA, "quoted hex is not supposed to be preserved\n");
+
+        size = sizeof(dword);
+        lret = RegQueryValueExA(key, "dword_unquoted_dec", NULL, NULL, (BYTE*)&dword, &size);
+        ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %d\n", lret);
+        ok(dword == 1, "unquoted dec is not supposed to be %d\n", dword);
+
+        size = sizeof(dword);
+        lret = RegQueryValueExA(key, "dword_quoted_dec", NULL, NULL, (BYTE*)&dword, &size);
+        ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %d\n", lret);
+        ok(dword == 1, "quoted dec is not supposed to be %d\n", dword);
+
+        size = 4;
+        lret = RegQueryValueExA(key, "binary_quoted", NULL, NULL, bytes, &size);
+        ok(lret == ERROR_SUCCESS, "RegQueryValueA, failed, error %d\n", lret);
+        ok(bytes[0] == 0xde && bytes[1] == 0xad && bytes[2] == 0xbe && bytes[3] == 0xef,
+            "binary quoted value was not preserved (it's 0x%02X%02X%02X%02X)\n",
+            0xff & bytes[0], 0xff & bytes[1], 0xff & bytes[2], 0xff & bytes[3]);
+
+        size = 4;
+        lret = RegQueryValueExA(key, "binary_unquoted", NULL, NULL, bytes, &size);
+        ok(lret == ERROR_SUCCESS, "RegQueryValueA, failed, error %d\n", lret);
+        ok(bytes[0] == 0xde && bytes[1] == 0xad && bytes[2] == 0xbe && bytes[3] == 0xef,
+            "binary unquoted value was not preserved (it's 0x%02X%02X%02X%02X)\n",
+            0xff & bytes[0], 0xff & bytes[1], 0xff & bytes[2], 0xff & bytes[3]);
+
+        hr = IRegistrar_StringUnregister(registrar, textW);
+        ok(SUCCEEDED(hr), "IRegistrar_StringUnregister failed, hr = 0x%08X\n", hr);
+        RegCloseKey(key);
+
+        HeapFree(GetProcessHeap(), 0, textW);
+    }
+    else
+        skip("allocating memory failed\n");
+
+    IRegistrar_Release(registrar);
+}
+
+START_TEST(registrar)
+{
+    CoInitialize(NULL);
+
+    test_registrar();
+
+    CoUninitialize();
+}
index aa47da7..b1de793 100644 (file)
@@ -6,10 +6,14 @@
 #define STANDALONE
 #include "wine/test.h"
 
+extern void func_atl_ax(void);
 extern void func_module(void);
+extern void func_registrar(void);
 
 const struct test winetest_testlist[] =
 {
+    { "atl_ax", func_atl_ax },
     { "module", func_module },
+    { "registrar", func_registrar },
     { 0, 0 }
 };