wmiutils: Implement IWbemPath::SetClassName.

oldstable
Hans Leidekker 2013-01-17 15:29:12 +01:00 committed by Alexandre Julliard
parent 23ae6e4ec4
commit ae6468c9a9
2 changed files with 62 additions and 5 deletions

View File

@ -447,18 +447,21 @@ static HRESULT WINAPI path_SetServer(
static const ULONGLONG flags =
WBEMPATH_INFO_PATH_HAD_SERVER | WBEMPATH_INFO_V1_COMPLIANT |
WBEMPATH_INFO_V2_COMPLIANT | WBEMPATH_INFO_CIM_COMPLIANT;
WCHAR *server;
TRACE("%p, %s\n", iface, debugstr_w(name));
heap_free( path->server );
if (name)
{
if (!(path->server = strdupW( name ))) return WBEM_E_OUT_OF_MEMORY;
if (!(server = strdupW( name ))) return WBEM_E_OUT_OF_MEMORY;
heap_free( path->server );
path->server = server;
path->len_server = strlenW( path->server );
path->flags |= flags;
}
else
{
heap_free( path->server );
path->server = NULL;
path->len_server = 0;
path->flags &= ~flags;
@ -593,10 +596,21 @@ static HRESULT WINAPI path_RemoveAllScopes(
static HRESULT WINAPI path_SetClassName(
IWbemPath *iface,
LPCWSTR Name)
LPCWSTR name)
{
FIXME("%p, %s\n", iface, debugstr_w(Name));
return E_NOTIMPL;
struct path *path = impl_from_IWbemPath( iface );
WCHAR *class;
TRACE("%p, %s\n", iface, debugstr_w(name));
if (!name) return WBEM_E_INVALID_PARAMETER;
if (!(class = strdupW( name ))) return WBEM_E_OUT_OF_MEMORY;
heap_free( path->class );
path->class = class;
path->len_class = strlenW( path->class );
path->flags |= WBEMPATH_INFO_V2_COMPLIANT | WBEMPATH_INFO_CIM_COMPLIANT;
return S_OK;
}
static HRESULT WINAPI path_GetClassName(

View File

@ -324,6 +324,44 @@ static void test_IWbemPath_GetClassName(void)
IWbemPath_Release( path );
}
static void test_IWbemPath_SetClassName(void)
{
static const WCHAR classW[] = {'c','l','a','s','s',0};
static const WCHAR emptyW[] = {0};
IWbemPath *path;
WCHAR buf[16];
ULONG len;
ULONGLONG flags;
HRESULT hr;
if (!(path = create_path())) return;
hr = IWbemPath_SetClassName( path, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
hr = IWbemPath_SetClassName( path, emptyW );
ok( hr == S_OK, "got %08x\n", hr );
hr = IWbemPath_SetClassName( path, classW );
ok( hr == S_OK, "got %08x\n", hr );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetClassName( path, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, classW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_CLASS_REF |
WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
WBEMPATH_INFO_CIM_COMPLIANT),
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
IWbemPath_Release( path );
}
static void test_IWbemPath_GetServer(void)
{
static const WCHAR dotW[] = {'.',0};
@ -438,6 +476,7 @@ static void test_IWbemPath_GetInfo(void)
static void test_IWbemPath_SetServer(void)
{
static const WCHAR serverW[] = {'s','e','r','v','e','r',0};
static const WCHAR emptyW[] = {0};
IWbemPath *path;
WCHAR buf[16];
ULONG len;
@ -453,6 +492,9 @@ static void test_IWbemPath_SetServer(void)
hr = IWbemPath_GetServer( path, &len, buf );
ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
hr = IWbemPath_SetServer( path, emptyW );
ok( hr == S_OK, "got %08x\n", hr );
hr = IWbemPath_SetServer( path, serverW );
ok( hr == S_OK, "got %08x\n", hr );
@ -493,6 +535,7 @@ START_TEST (path)
test_IWbemPath_SetText();
test_IWbemPath_GetText();
test_IWbemPath_GetClassName();
test_IWbemPath_SetClassName();
test_IWbemPath_GetServer();
test_IWbemPath_GetInfo();
test_IWbemPath_SetServer();