[HNETCFG_WINETEST] Import from Wine 3.0. CORE-14225
authorAmine Khaldi <amine.khaldi@reactos.org>
Thu, 18 Jan 2018 23:31:47 +0000 (00:31 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Thu, 18 Jan 2018 23:31:47 +0000 (00:31 +0100)
modules/rostests/winetests/CMakeLists.txt
modules/rostests/winetests/hnetcfg/CMakeLists.txt [new file with mode: 0644]
modules/rostests/winetests/hnetcfg/policy.c [new file with mode: 0644]
modules/rostests/winetests/hnetcfg/testlist.c [new file with mode: 0644]

index 52d1114..01ab53e 100644 (file)
@@ -31,6 +31,7 @@ add_subdirectory(fusion)
 add_subdirectory(gdi32)
 add_subdirectory(gdiplus)
 add_subdirectory(hlink)
+add_subdirectory(hnetcfg)
 add_subdirectory(imagehlp)
 add_subdirectory(imm32)
 add_subdirectory(inetcomm)
diff --git a/modules/rostests/winetests/hnetcfg/CMakeLists.txt b/modules/rostests/winetests/hnetcfg/CMakeLists.txt
new file mode 100644 (file)
index 0000000..396c20e
--- /dev/null
@@ -0,0 +1,7 @@
+
+add_definitions(-DUSE_WINE_TODOS)
+add_executable(hnetcfg_winetest policy.c testlist.c)
+target_link_libraries(hnetcfg_winetest uuid)
+set_module_type(hnetcfg_winetest win32cui)
+add_importlibs(hnetcfg_winetest ole32 msvcrt kernel32)
+add_rostests_file(TARGET hnetcfg_winetest)
diff --git a/modules/rostests/winetests/hnetcfg/policy.c b/modules/rostests/winetests/hnetcfg/policy.c
new file mode 100644 (file)
index 0000000..7b5bef0
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2016 Alistair Leslie-Hughes
+ *
+ * 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
+ */
+#define COBJMACROS
+#include <stdio.h>
+
+#include "windows.h"
+#include "ole2.h"
+#include "oleauto.h"
+#include "olectl.h"
+#include "dispex.h"
+
+#include "wine/test.h"
+
+#include "netfw.h"
+
+static void test_policy2_rules(INetFwPolicy2 *policy2)
+{
+    HRESULT hr;
+    INetFwRules *rules, *rules2;
+    INetFwServiceRestriction *restriction;
+
+    hr = INetFwPolicy2_QueryInterface(policy2, &IID_INetFwRules, (void**)&rules);
+    ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
+
+    hr = INetFwPolicy2_get_Rules(policy2, &rules);
+    ok(hr == S_OK, "got %08x\n", hr);
+
+    hr = INetFwPolicy2_get_Rules(policy2, &rules2);
+    ok(hr == S_OK, "got %08x\n", hr);
+    ok(rules == rules2, "Different pointers\n");
+
+    hr = INetFwPolicy2_get_ServiceRestriction(policy2, &restriction);
+    todo_wine ok(hr == S_OK, "got %08x\n", hr);
+    if(hr == S_OK)
+    {
+        INetFwRules *rules3;
+
+        hr = INetFwServiceRestriction_get_Rules(restriction, &rules3);
+        ok(hr == S_OK, "got %08x\n", hr);
+        ok(rules != rules3, "same pointers\n");
+
+        if(rules3)
+            INetFwRules_Release(rules3);
+        INetFwServiceRestriction_Release(restriction);
+    }
+
+    INetFwRules_Release(rules);
+    INetFwRules_Release(rules2);
+}
+
+static void test_interfaces(void)
+{
+    INetFwMgr *manager;
+    INetFwPolicy *policy;
+    INetFwPolicy2 *policy2;
+    HRESULT hr;
+
+    hr = CoCreateInstance(&CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
+            &IID_INetFwMgr, (void**)&manager);
+    ok(hr == S_OK, "NetFwMgr create failed: %08x\n", hr);
+
+    hr = INetFwMgr_QueryInterface(manager, &IID_INetFwPolicy, (void**)&policy);
+    ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
+
+    hr = INetFwMgr_QueryInterface(manager, &IID_INetFwPolicy2, (void**)&policy2);
+    ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
+
+    hr = INetFwMgr_get_LocalPolicy(manager, &policy);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    hr = INetFwPolicy_QueryInterface(policy, &IID_INetFwPolicy2, (void**)&policy2);
+    ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
+
+    INetFwPolicy_Release(policy);
+
+    hr = CoCreateInstance(&CLSID_NetFwPolicy2, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
+            &IID_INetFwPolicy2, (void**)&policy2);
+    if(hr == S_OK)
+    {
+        test_policy2_rules(policy2);
+
+        INetFwPolicy2_Release(policy2);
+    }
+    else
+        win_skip("NetFwPolicy2 object is not supported: %08x\n", hr);
+
+    INetFwMgr_Release(manager);
+}
+
+START_TEST(policy)
+{
+    INetFwMgr *manager;
+    HRESULT hr;
+
+    CoInitialize(NULL);
+
+    hr = CoCreateInstance(&CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
+            &IID_INetFwMgr, (void**)&manager);
+    if(FAILED(hr))
+    {
+        win_skip("NetFwMgr object is not supported: %08x\n", hr);
+        CoUninitialize();
+        return;
+    }
+
+    INetFwMgr_Release(manager);
+
+    test_interfaces();
+
+
+    CoUninitialize();
+}
diff --git a/modules/rostests/winetests/hnetcfg/testlist.c b/modules/rostests/winetests/hnetcfg/testlist.c
new file mode 100644 (file)
index 0000000..4b5b1f1
--- /dev/null
@@ -0,0 +1,12 @@
+/* Automatically generated file; DO NOT EDIT!! */
+
+#define STANDALONE
+#include <wine/test.h>
+
+extern void func_policy(void);
+
+const struct test winetest_testlist[] =
+{
+    { "policy", func_policy },
+    { 0, 0 }
+};