https://git.reactos.org/?p=reactos.git;a=commitdiff;h=21e30f3f67ece980ae488…
commit 21e30f3f67ece980ae488780cc3e80e9fc5692d4
Author: Doug Lyons <douglyons(a)douglyons.com>
AuthorDate: Fri Aug 4 08:54:31 2023 -0500
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri Aug 4 16:54:31 2023 +0300
[SHELL32_APITEST] Add test for Control Panel's GetDisplayNameOf (#5495)
New regression test for shell32!GetDisplayNameOf, showing that the return
value of the function will be 'S_FALSE' when the first argument is NULL.
Also, the returned STRRET structure data is not modified by this call.
CORE-18841
---
modules/rostests/apitests/shell32/CMakeLists.txt | 1 +
.../rostests/apitests/shell32/GetDisplayNameOf.cpp | 44 ++++++++++++++++++++++
modules/rostests/apitests/shell32/testlist.c | 2 +
3 files changed, 47 insertions(+)
diff --git a/modules/rostests/apitests/shell32/CMakeLists.txt
b/modules/rostests/apitests/shell32/CMakeLists.txt
index 53c87297d89..797e6e5ed1c 100644
--- a/modules/rostests/apitests/shell32/CMakeLists.txt
+++ b/modules/rostests/apitests/shell32/CMakeLists.txt
@@ -15,6 +15,7 @@ list(APPEND SOURCE
DragDrop.cpp
ExtractIconEx.cpp
FindExecutable.cpp
+ GetDisplayNameOf.cpp
IShellFolderViewCB.cpp
OpenAs_RunDLL.cpp
PathResolve.cpp
diff --git a/modules/rostests/apitests/shell32/GetDisplayNameOf.cpp
b/modules/rostests/apitests/shell32/GetDisplayNameOf.cpp
new file mode 100644
index 00000000000..0211715fb1c
--- /dev/null
+++ b/modules/rostests/apitests/shell32/GetDisplayNameOf.cpp
@@ -0,0 +1,44 @@
+/*
+ * PROJECT: ReactOS API tests
+ * LICENSE: LGPL-2.1+ (
https://spdx.org/licenses/LGPL-2.1+)
+ * PURPOSE: Test for GetDisplayNameOf
+ * COPYRIGHT: Copyright 2023 Mark Jansen <mark.jansen(a)reactos.org>
+ * Copyright 2023 Doug Lyons <douglyons(a)douglyons.com>
+ */
+
+#include "shelltest.h"
+#include <stdio.h>
+#include <shellutils.h>
+
+START_TEST(GetDisplayNameOf)
+{
+ HRESULT hr;
+ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+
+ CComPtr<IShellFolder> spPanel;
+
+ hr = CoCreateInstance(CLSID_ControlPanel, NULL, CLSCTX_ALL,
+ IID_PPV_ARG(IShellFolder, &spPanel));
+ ok_hr(hr, S_OK);
+ if (SUCCEEDED(hr))
+ {
+ STRRET ret, expected;
+
+ memset(&ret, 'a', sizeof(ret));
+ memset(&expected, 'a', sizeof(expected));
+ hr = spPanel->GetDisplayNameOf(NULL, SHGDN_NORMAL, &ret);
+
+ /* Return value is expected to be 'S_FALSE', which is out-of-spec
behavior.
+ * The data after function call is expected to be unchanged. */
+ ok_hex(hr, S_FALSE);
+ ok(memcmp(&ret, &expected, sizeof(ret)) == 0, "Data was
changed!\n");
+
+ /* Repeat the same test with SHGDN_FORPARSING */
+ memset(&ret, 'a', sizeof(ret));
+ memset(&expected, 'a', sizeof(expected));
+ hr = spPanel->GetDisplayNameOf(NULL, SHGDN_FORPARSING, &ret);
+
+ ok_hex(hr, S_FALSE);
+ ok(memcmp(&ret, &expected, sizeof(ret)) == 0, "Data was
changed!\n");
+ }
+}
diff --git a/modules/rostests/apitests/shell32/testlist.c
b/modules/rostests/apitests/shell32/testlist.c
index 2c65335551f..5522cb0b659 100644
--- a/modules/rostests/apitests/shell32/testlist.c
+++ b/modules/rostests/apitests/shell32/testlist.c
@@ -16,6 +16,7 @@ extern void func_CUserNotification(void);
extern void func_DragDrop(void);
extern void func_ExtractIconEx(void);
extern void func_FindExecutable(void);
+extern void func_GetDisplayNameOf(void);
extern void func_IShellFolderViewCB(void);
extern void func_menu(void);
extern void func_OpenAs_RunDLL(void);
@@ -49,6 +50,7 @@ const struct test winetest_testlist[] =
{ "DragDrop", func_DragDrop },
{ "ExtractIconEx", func_ExtractIconEx },
{ "FindExecutable", func_FindExecutable },
+ { "GetDisplayNameOf", func_GetDisplayNameOf },
{ "IShellFolderViewCB", func_IShellFolderViewCB },
{ "menu", func_menu },
{ "OpenAs_RunDLL", func_OpenAs_RunDLL },