mirror of
https://github.com/reactos/reactos.git
synced 2025-06-12 08:48:30 +00:00
Strengthen GetDisplayNameOf testcase. CORE-9281, CORE-16444
This commit is contained in:
parent
deb928c4bc
commit
a105b5d355
1 changed files with 74 additions and 23 deletions
|
@ -3,6 +3,7 @@
|
||||||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
* PURPOSE: Tests for fontext GetDisplayNameOf behavior
|
* PURPOSE: Tests for fontext GetDisplayNameOf behavior
|
||||||
* COPYRIGHT: Copyright 2021 Mark Jansen <mark.jansen@reactos.org>
|
* COPYRIGHT: Copyright 2021 Mark Jansen <mark.jansen@reactos.org>
|
||||||
|
* Copyright 2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ntstatus.h>
|
#include <ntstatus.h>
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
#include <shellutils.h>
|
#include <shellutils.h>
|
||||||
|
#include <versionhelpers.h>
|
||||||
#include "wine/test.h"
|
#include "wine/test.h"
|
||||||
|
|
||||||
static HRESULT Initialize(CComPtr<IShellFolder>& spFolder)
|
static HRESULT Initialize(CComPtr<IShellFolder>& spFolder)
|
||||||
|
@ -39,45 +41,68 @@ static HRESULT Initialize(CComPtr<IShellFolder>& spFolder)
|
||||||
|
|
||||||
hr = desktopFolder->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &spFolder));
|
hr = desktopFolder->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &spFolder));
|
||||||
ok_hex(hr, S_OK);
|
ok_hex(hr, S_OK);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
skip("BindToObject failed\n");
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Test_GetDisplayNameOf(CComPtr<IShellFolder>& spFolder)
|
static void
|
||||||
|
Test_GetDisplayNameOf(CComPtr<IShellFolder>& spFolder,
|
||||||
|
DWORD dwFlags, LPCWSTR text, BOOL fRelative)
|
||||||
{
|
{
|
||||||
CComPtr<IEnumIDList> fontsEnum;
|
CComPtr<IEnumIDList> fontsEnum;
|
||||||
HRESULT hr = spFolder->EnumObjects(NULL, SHCONTF_NONFOLDERS, &fontsEnum);
|
HRESULT hr = spFolder->EnumObjects(NULL, SHCONTF_NONFOLDERS, &fontsEnum);
|
||||||
|
|
||||||
ok_hex(hr, S_OK);
|
ok_hex(hr, S_OK);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
skip("EnumObjects failed\n");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CComHeapPtr<ITEMIDLIST> fontPidl;
|
BOOL bFound = FALSE;
|
||||||
ULONG fetched = 0;
|
for (;;)
|
||||||
hr = fontsEnum->Next(1, &fontPidl, &fetched);
|
{
|
||||||
STRRET strret;
|
CComHeapPtr<ITEMIDLIST> fontPidl;
|
||||||
hr = spFolder->GetDisplayNameOf(fontPidl, SHGDN_FORPARSING, &strret);
|
ULONG fetched = 0;
|
||||||
ok_hex(hr, S_OK);
|
hr = fontsEnum->Next(1, &fontPidl, &fetched);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr) || hr == S_FALSE)
|
||||||
return;
|
break;
|
||||||
|
|
||||||
WCHAR Buf[MAX_PATH];
|
STRRET strret;
|
||||||
hr = StrRetToBufW(&strret, fontPidl, Buf, _countof(Buf));
|
hr = spFolder->GetDisplayNameOf(fontPidl, dwFlags, &strret);
|
||||||
ok_hex(hr, S_OK);
|
if (FAILED(hr))
|
||||||
if (FAILED(hr))
|
continue;
|
||||||
return;
|
|
||||||
|
|
||||||
// On 2k3 where this is not a custom IShellFolder, it will return something like:
|
WCHAR Buf[MAX_PATH];
|
||||||
// 'C:\\WINDOWS\\Fonts\\arial.ttf'
|
hr = StrRetToBufW(&strret, fontPidl, Buf, _countof(Buf));
|
||||||
// On Vista+ this results in something like:
|
if (FAILED(hr))
|
||||||
// 'C:\\Windows\\Fonts\\System Bold'
|
continue;
|
||||||
BOOL bRelative = PathIsRelativeW(Buf);
|
|
||||||
trace("Path: %s\n", wine_dbgstr_w(Buf));
|
trace("Path: %s\n", wine_dbgstr_w(Buf));
|
||||||
ok(bRelative == FALSE, "Path not relative? (%s)\n", wine_dbgstr_w(Buf));
|
if (lstrcmpiW(text, Buf) == 0)
|
||||||
|
{
|
||||||
|
bFound = TRUE;
|
||||||
|
ok_int(PathIsRelativeW(Buf), fRelative);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ok_int(bFound, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
START_TEST(GetDisplayNameOf)
|
START_TEST(GetDisplayNameOf)
|
||||||
{
|
{
|
||||||
|
if (IsWindowsVistaOrGreater())
|
||||||
|
{
|
||||||
|
skip("Vista+\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -85,7 +110,33 @@ START_TEST(GetDisplayNameOf)
|
||||||
HRESULT hr = Initialize(spFolder);
|
HRESULT hr = Initialize(spFolder);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
Test_GetDisplayNameOf(spFolder);
|
WCHAR szPath[MAX_PATH];
|
||||||
|
SHGetFolderPathW(NULL, CSIDL_FONTS, NULL, 0, szPath);
|
||||||
|
PathAppendW(szPath, L"arial.ttf");
|
||||||
|
|
||||||
|
trace("SHGDN_NORMAL\n");
|
||||||
|
Test_GetDisplayNameOf(spFolder, SHGDN_NORMAL, L"arial.ttf", TRUE);
|
||||||
|
|
||||||
|
trace("SHGDN_INFOLDER\n");
|
||||||
|
Test_GetDisplayNameOf(spFolder, SHGDN_INFOLDER, L"arial.ttf", TRUE);
|
||||||
|
|
||||||
|
trace("SHGDN_FORPARSING\n");
|
||||||
|
Test_GetDisplayNameOf(spFolder, SHGDN_FORPARSING, szPath, FALSE);
|
||||||
|
|
||||||
|
trace("SHGDN_INFOLDER | SHGDN_FORPARSING\n");
|
||||||
|
Test_GetDisplayNameOf(spFolder, SHGDN_INFOLDER | SHGDN_FORPARSING, L"arial.ttf", TRUE);
|
||||||
|
|
||||||
|
trace("SHGDN_FORADDRESSBAR\n");
|
||||||
|
Test_GetDisplayNameOf(spFolder, SHGDN_FORADDRESSBAR, L"arial.ttf", TRUE);
|
||||||
|
|
||||||
|
trace("SHGDN_INFOLDER | SHGDN_FORADDRESSBAR\n");
|
||||||
|
Test_GetDisplayNameOf(spFolder, SHGDN_INFOLDER | SHGDN_FORADDRESSBAR, L"arial.ttf", TRUE);
|
||||||
|
|
||||||
|
trace("SHGDN_FORPARSING | SHGDN_FORADDRESSBAR\n");
|
||||||
|
Test_GetDisplayNameOf(spFolder, SHGDN_FORPARSING | SHGDN_FORADDRESSBAR, szPath, FALSE);
|
||||||
|
|
||||||
|
trace("SHGDN_INFOLDER | SHGDN_FORPARSING | SHGDN_FORADDRESSBAR\n");
|
||||||
|
Test_GetDisplayNameOf(spFolder, SHGDN_INFOLDER | SHGDN_FORPARSING | SHGDN_FORADDRESSBAR, L"arial.ttf", TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue