msvcirt: Add implementation of streambuf::sputbackc.
[wine.git] / dlls / netcfgx / tests / netcfgx.c
blobfda39f5773be00f50e76e481775ce54576c46d58
1 /*
2 * Copyright 2014 Alistair Leslie-Hughes
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 #define WIN32_LEAN_AND_MEAN
19 #include <stdio.h>
21 #define COBJMACROS
23 #include "netcfgx.h"
24 #include "wine/test.h"
26 static void create_configuration(void)
28 static const WCHAR tcpipW[] = {'M','S','_','T','C','P','I','P',0};
29 static const WCHAR myclient[] = {'M','Y',' ','C','L','I','E','N','T',0};
30 HRESULT hr;
31 INetCfg *config = NULL;
32 INetCfgLock *netlock = NULL;
33 INetCfgComponent *component = NULL;
34 LPWSTR client = NULL;
36 hr = CoCreateInstance( &CLSID_CNetCfg, NULL, CLSCTX_ALL, &IID_INetCfg, (LPVOID*)&config);
37 ok(hr == S_OK, "Failed to create object\n");
38 if(SUCCEEDED(hr))
40 hr = INetCfg_QueryInterface(config, &IID_INetCfgLock, (LPVOID*)&netlock);
41 ok(hr == S_OK, "got 0x%08x\n", hr);
43 hr = INetCfgLock_AcquireWriteLock(netlock, 5000, myclient, &client);
44 ok(hr == S_OK ||
45 hr == E_ACCESSDENIED /* Not run as admin */, "got 0x%08x\n", hr);
46 if(hr == S_OK)
48 trace("Lock value: %s\n", wine_dbgstr_w(client));
49 CoTaskMemFree(client);
51 else if(hr == E_ACCESSDENIED)
52 trace("Not run with Admin permissions\n");
54 hr = INetCfg_Initialize(config, NULL);
55 ok(hr == S_OK, "got 0x%08x\n", hr);
57 /* AcquireWriteLock needs to be run before Initialize */
58 hr = INetCfgLock_AcquireWriteLock(netlock, 5000, myclient, &client);
59 todo_wine ok(hr == NETCFG_E_ALREADY_INITIALIZED || hr == E_ACCESSDENIED, "got 0x%08x\n", hr);
61 hr = INetCfg_FindComponent(config, tcpipW, &component);
62 todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
63 if(hr == S_OK)
65 INetCfgComponent_Release(component);
68 hr = INetCfg_Apply(config);
69 todo_wine ok(hr == S_OK || hr == NETCFG_E_NO_WRITE_LOCK, "got 0x%08x\n", hr);
71 hr = INetCfg_Uninitialize(config);
72 ok(hr == S_OK, "got 0x%08x\n", hr);
74 hr = INetCfgLock_ReleaseWriteLock(netlock);
75 ok(hr == S_OK, "got 0x%08x\n", hr);
77 INetCfgLock_Release(netlock);
78 INetCfg_Release(config);
82 START_TEST(netcfgx)
84 HRESULT hr;
86 hr = CoInitialize(0);
87 ok( hr == S_OK, "failed to init com\n");
88 if (hr != S_OK)
89 return;
91 create_configuration();
93 CoUninitialize();