Module: wine Branch: master Commit: 041ab23d0b49a98b169db00c20f77fd1d7c9c071 URL: http://source.winehq.org/git/wine.git/?a=commit;h=041ab23d0b49a98b169db00c20...
Author: Hans Leidekker hans@codeweavers.com Date: Thu Jan 8 13:54:07 2015 +0100
wbemdisp/tests: Add initial tests.
---
configure | 1 + configure.ac | 1 + dlls/wbemdisp/tests/Makefile.in | 5 ++ dlls/wbemdisp/tests/wbemdisp.c | 102 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+)
diff --git a/configure b/configure index 79d6632..062287e 100755 --- a/configure +++ b/configure @@ -17468,6 +17468,7 @@ wine_fn_config_dll vwin32.vxd enable_win16 wine_fn_config_dll w32skrnl enable_win16 wine_fn_config_dll w32sys.dll16 enable_win16 wine_fn_config_dll wbemdisp enable_wbemdisp clean +wine_fn_config_test dlls/wbemdisp/tests wbemdisp_test wine_fn_config_dll wbemprox enable_wbemprox clean wine_fn_config_test dlls/wbemprox/tests wbemprox_test wine_fn_config_dll webservices enable_webservices implib diff --git a/configure.ac b/configure.ac index b67a7e7..50efb9f 100644 --- a/configure.ac +++ b/configure.ac @@ -3292,6 +3292,7 @@ WINE_CONFIG_DLL(vwin32.vxd,enable_win16) WINE_CONFIG_DLL(w32skrnl,enable_win16) WINE_CONFIG_DLL(w32sys.dll16,enable_win16) WINE_CONFIG_DLL(wbemdisp,,[clean]) +WINE_CONFIG_TEST(dlls/wbemdisp/tests) WINE_CONFIG_DLL(wbemprox,,[clean]) WINE_CONFIG_TEST(dlls/wbemprox/tests) WINE_CONFIG_DLL(webservices,,[implib]) diff --git a/dlls/wbemdisp/tests/Makefile.in b/dlls/wbemdisp/tests/Makefile.in new file mode 100644 index 0000000..f509d37 --- /dev/null +++ b/dlls/wbemdisp/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = wbemdisp.dll +IMPORTS = oleaut32 ole32 + +C_SRCS = \ + wbemdisp.c diff --git a/dlls/wbemdisp/tests/wbemdisp.c b/dlls/wbemdisp/tests/wbemdisp.c new file mode 100644 index 0000000..8c0b628 --- /dev/null +++ b/dlls/wbemdisp/tests/wbemdisp.c @@ -0,0 +1,102 @@ +/* + * Copyright 2015 Hans Leidekker for CodeWeavers + * + * 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 "initguid.h" +#include "objidl.h" +#include "wbemdisp.h" +#include "wine/test.h" + +DEFINE_GUID(CLSID_WINMGMTS,0x172bddf8,0xceea,0x11d1,0x8b,0x05,0x00,0x60,0x08,0x06,0xd9,0xb6); + +static void test_ParseDisplayName(void) +{ + static const WCHAR name1[] = + {'w','i','n','m','g','m','t','s',':',0}; + static const WCHAR name2[] = + {'w','i','n','m','g','m','t','s',':','\','\','.','\','r','o','o','t','\','c','i','m','v','2',0}; + static const WCHAR name3[] = + {'w','i','n','m','g','m','t','s',':','\','\','.','\','r','o','o','t','\','c','i','m','v','2',':', + 'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k','.', + 'D','e','v','i','c','e','I','D','=',''','C',':',''',0}; + static const WCHAR name4[] = + {'w','i','n','m','g','m','t','s',':','\','\','.','\','r','o','o','t','\','c','i','m','v','2',':', + 'W','i','n','3','2','_','S','e','r','v','i','c','e',0}; + static const struct + { + const WCHAR *name; + HRESULT hr; + REFIID iid; + ULONG eaten; + } tests[] = + { + { name1, S_OK, &IID_ISWbemServices, sizeof(name1)/sizeof(name1[0]) - 1 }, + { name2, S_OK, &IID_ISWbemServices, sizeof(name2)/sizeof(name2[0]) - 1 }, + { name3, S_OK, &IID_ISWbemObject, sizeof(name3)/sizeof(name3[0]) - 1 }, + { name4, S_OK, &IID_ISWbemObject, sizeof(name4)/sizeof(name4[0]) - 1 } + }; + IParseDisplayName *displayname; + IBindCtx *ctx; + IMoniker *moniker; + IUnknown *obj; + BSTR str; + ULONG i, eaten; + HRESULT hr; + + hr = CoCreateInstance( &CLSID_WINMGMTS, NULL, CLSCTX_INPROC_SERVER, &IID_IParseDisplayName, (void **)&displayname ); + if (hr != S_OK) + { + win_skip( "can't create instance of WINMGMTS\n" ); + return; + } + + hr = CreateBindCtx( 0, &ctx ); + ok( hr == S_OK, "got %x\n", hr ); + + for (i =0; i < sizeof(tests)/sizeof(tests[0]); i++) + { + str = SysAllocString( tests[i].name ); + eaten = 0xdeadbeef; + moniker = NULL; + hr = IParseDisplayName_ParseDisplayName( displayname, NULL, str, &eaten, &moniker ); + SysFreeString( str ); + ok( hr == tests[i].hr, "%u: got %x\n", i, hr ); + ok( eaten == tests[i].eaten, "%u: got %u\n", i, eaten ); + if (moniker) + { + obj = NULL; + hr = IMoniker_BindToObject( moniker, ctx, NULL, tests[i].iid, (void **)&obj ); + ok( hr == S_OK, "%u: got %x\n", i, hr ); + if (obj) IUnknown_Release( obj ); + IMoniker_Release( moniker ); + } + } + + IBindCtx_Release( ctx ); + IParseDisplayName_Release( displayname ); +} + +START_TEST(wbemdisp) +{ + CoInitialize( NULL ); + test_ParseDisplayName(); + CoUninitialize(); +}