Reactos
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: Test for GetDisplayNameOf
5 * COPYRIGHT: Copyright 2023 Mark Jansen <mark.jansen@reactos.org>
6 * Copyright 2023 Doug Lyons <douglyons@douglyons.com>
7 */
8
9#include "shelltest.h"
10#include <stdio.h>
11#include <shellutils.h>
12
13START_TEST(GetDisplayNameOf)
14{
15 HRESULT hr;
16 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
17
18 CComPtr<IShellFolder> spPanel;
19
20 hr = CoCreateInstance(CLSID_ControlPanel, NULL, CLSCTX_ALL,
21 IID_PPV_ARG(IShellFolder, &spPanel));
22 ok_hr(hr, S_OK);
23 if (SUCCEEDED(hr))
24 {
25 STRRET ret, expected;
26
27 memset(&ret, 'a', sizeof(ret));
28 memset(&expected, 'a', sizeof(expected));
29 hr = spPanel->GetDisplayNameOf(NULL, SHGDN_NORMAL, &ret);
30
31 /* Return value is expected to be 'S_FALSE', which is out-of-spec behavior.
32 * The data after function call is expected to be unchanged. */
33 ok_hex(hr, S_FALSE);
34 ok(memcmp(&ret, &expected, sizeof(ret)) == 0, "Data was changed!\n");
35
36 /* Repeat the same test with SHGDN_FORPARSING */
37 memset(&ret, 'a', sizeof(ret));
38 memset(&expected, 'a', sizeof(expected));
39 hr = spPanel->GetDisplayNameOf(NULL, SHGDN_FORPARSING, &ret);
40
41 ok_hex(hr, S_FALSE);
42 ok(memcmp(&ret, &expected, sizeof(ret)) == 0, "Data was changed!\n");
43 }
44}