Hans Leidekker : wmiutils: Implement IWbemPath::GetNamespaceAt.

Alexandre Julliard julliard at winehq.org
Thu Jan 17 14:48:50 CST 2013


Module: wine
Branch: master
Commit: af84c4c7a9a53caccf337fe6071777bfd360fd85
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=af84c4c7a9a53caccf337fe6071777bfd360fd85

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Thu Jan 17 15:29:48 2013 +0100

wmiutils: Implement IWbemPath::GetNamespaceAt.

---

 dlls/wmiutils/path.c       |   16 ++++++++----
 dlls/wmiutils/tests/path.c |   57 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 5 deletions(-)

diff --git a/dlls/wmiutils/path.c b/dlls/wmiutils/path.c
index 6e63e26..4e5cd64 100644
--- a/dlls/wmiutils/path.c
+++ b/dlls/wmiutils/path.c
@@ -509,12 +509,18 @@ static HRESULT WINAPI path_SetNamespaceAt(
 
 static HRESULT WINAPI path_GetNamespaceAt(
     IWbemPath *iface,
-    ULONG uIndex,
-    ULONG *puNameBufLength,
-    LPWSTR pName)
+    ULONG idx,
+    ULONG *len,
+    LPWSTR name)
 {
-    FIXME("%p, %u, %p, %p\n", iface, uIndex, puNameBufLength, pName);
-    return E_NOTIMPL;
+    struct path *path = impl_from_IWbemPath( iface );
+
+    TRACE("%p, %u, %p, %p\n", iface, idx, len, name);
+
+    if (!len || (*len && !name) || idx >= path->num_namespaces) return WBEM_E_INVALID_PARAMETER;
+    if (*len > path->len_namespaces[idx]) strcpyW( name, path->namespaces[idx] );
+    *len = path->len_namespaces[idx] + 1;
+    return S_OK;
 }
 
 static HRESULT WINAPI path_RemoveNamespaceAt(
diff --git a/dlls/wmiutils/tests/path.c b/dlls/wmiutils/tests/path.c
index e21593d..9911318 100644
--- a/dlls/wmiutils/tests/path.c
+++ b/dlls/wmiutils/tests/path.c
@@ -528,6 +528,62 @@ static void test_IWbemPath_SetServer(void)
     IWbemPath_Release( path );
 }
 
+static void test_IWbemPath_GetNamespaceAt(void)
+{
+    static const WCHAR rootW[] = {'r','o','o','t',0};
+    static const WCHAR cimv2W[] = {'c','i','m','v','2',0};
+    IWbemPath *path;
+    HRESULT hr;
+    WCHAR buf[32];
+    ULONG len;
+
+    if (!(path = create_path())) return;
+
+    hr = IWbemPath_GetNamespaceAt( path, 0, NULL, NULL );
+    ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
+
+    len = 0;
+    hr = IWbemPath_GetNamespaceAt( path, 0, &len, NULL );
+    ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
+
+    len = sizeof(buf) / sizeof(buf[0]);
+    hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
+    ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
+
+    len = sizeof(buf) / sizeof(buf[0]);
+    hr = IWbemPath_GetNamespaceAt( path, 0, &len, NULL );
+    ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
+    ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
+
+    hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    len = 0;
+    hr = IWbemPath_GetNamespaceAt( path, 2, &len, NULL );
+    ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
+
+    len = sizeof(buf) / sizeof(buf[0]);
+    hr = IWbemPath_GetNamespaceAt( path, 0, &len, NULL );
+    ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
+    ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
+
+    buf[0] = 0;
+    len = sizeof(buf) / sizeof(buf[0]);
+    hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( !lstrcmpW( buf, rootW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
+    ok( len == lstrlenW( rootW ) + 1, "unexpected length %u\n", len );
+
+    buf[0] = 0;
+    len = sizeof(buf) / sizeof(buf[0]);
+    hr = IWbemPath_GetNamespaceAt( path, 1, &len, buf );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( !lstrcmpW( buf, cimv2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
+    ok( len == lstrlenW( cimv2W ) + 1, "unexpected length %u\n", len );
+
+    IWbemPath_Release( path );
+}
+
 START_TEST (path)
 {
     CoInitialize( NULL );
@@ -539,6 +595,7 @@ START_TEST (path)
     test_IWbemPath_GetServer();
     test_IWbemPath_GetInfo();
     test_IWbemPath_SetServer();
+    test_IWbemPath_GetNamespaceAt();
 
     CoUninitialize();
 }




More information about the wine-cvs mailing list