mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[FONTEXT_APITEST] Test more cases for GetDisplayNameOf
This commit is contained in:
parent
20c98b3144
commit
23b6397ae9
2 changed files with 119 additions and 14 deletions
|
@ -15,9 +15,27 @@
|
|||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
#include <shellutils.h>
|
||||
#include <versionhelpers.h>
|
||||
#include "wine/test.h"
|
||||
|
||||
static HRESULT Initialize(CComPtr<IShellFolder>& spFolder)
|
||||
static const CLSID CLSID_FontExt = { 0xBD84B380, 0x8CA2, 0x1069, { 0xAB, 0x1D, 0x08, 0x00, 0x09, 0x48, 0xF5, 0x34 } };
|
||||
static BOOL g_bFontFolderWithShellView = FALSE;
|
||||
static BOOL g_bVistaWorkaround = FALSE;
|
||||
|
||||
static HRESULT GetDisplayName(CComPtr<IShellFolder>& spFolder, LPCITEMIDLIST pidlRelative, SHGDNF uFlags, WCHAR Buf[MAX_PATH])
|
||||
{
|
||||
STRRET strret;
|
||||
HRESULT hr = spFolder->GetDisplayNameOf(pidlRelative, uFlags, &strret);
|
||||
ok_hex(hr, S_OK);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
hr = StrRetToBufW(&strret, pidlRelative, Buf, MAX_PATH);
|
||||
ok_hex(hr, S_OK);
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT Initialize(CComPtr<IShellFolder>& spFolder, WCHAR FolderName[MAX_PATH])
|
||||
{
|
||||
WCHAR Path[MAX_PATH] = {0};
|
||||
HRESULT hr = SHGetFolderPathW(NULL, CSIDL_FONTS, NULL, 0, Path);
|
||||
|
@ -39,10 +57,21 @@ static HRESULT Initialize(CComPtr<IShellFolder>& spFolder)
|
|||
|
||||
hr = desktopFolder->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &spFolder));
|
||||
ok_hex(hr, S_OK);
|
||||
return hr;
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
|
||||
CComPtr<IShellFolder> psfParent;
|
||||
LPCITEMIDLIST pidlRelative = NULL;
|
||||
hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psfParent), &pidlRelative);
|
||||
ok_hex(hr, S_OK);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
return GetDisplayName(psfParent, pidlRelative, SHGDN_NORMAL, FolderName);
|
||||
}
|
||||
|
||||
static void Test_GetDisplayNameOf(CComPtr<IShellFolder>& spFolder)
|
||||
static void Test_GetDisplayNameOf(CComPtr<IShellFolder>& spFolder, const WCHAR* FolderName)
|
||||
{
|
||||
CComPtr<IEnumIDList> fontsEnum;
|
||||
HRESULT hr = spFolder->EnumObjects(NULL, SHCONTF_NONFOLDERS, &fontsEnum);
|
||||
|
@ -52,27 +81,91 @@ static void Test_GetDisplayNameOf(CComPtr<IShellFolder>& spFolder)
|
|||
return;
|
||||
|
||||
CComHeapPtr<ITEMIDLIST> fontPidl;
|
||||
|
||||
// Get the first item from the folder
|
||||
ULONG fetched = 0;
|
||||
hr = fontsEnum->Next(1, &fontPidl, &fetched);
|
||||
STRRET strret;
|
||||
hr = spFolder->GetDisplayNameOf(fontPidl, SHGDN_FORPARSING, &strret);
|
||||
ok_hex(hr, S_OK);
|
||||
if (FAILED(hr))
|
||||
return;
|
||||
|
||||
WCHAR Buf[MAX_PATH];
|
||||
hr = StrRetToBufW(&strret, fontPidl, Buf, _countof(Buf));
|
||||
ok_hex(hr, S_OK);
|
||||
if (FAILED(hr))
|
||||
|
||||
WCHAR Buf[MAX_PATH], *Ptr;
|
||||
if (FAILED(GetDisplayName(spFolder, fontPidl, SHGDN_FORPARSING, Buf)))
|
||||
return;
|
||||
|
||||
// On 2k3 where this is not a custom IShellFolder, it will return something like:
|
||||
// Same for Vista??
|
||||
// 'C:\\WINDOWS\\Fonts\\arial.ttf'
|
||||
// On Vista+ this results in something like:
|
||||
// On 7+ this results is:
|
||||
// 'C:\\Windows\\Fonts\\System Bold'
|
||||
BOOL bRelative = PathIsRelativeW(Buf);
|
||||
Ptr = PathFindNextComponentW(Buf);
|
||||
trace("Path: %s\n", wine_dbgstr_w(Buf));
|
||||
ok(bRelative == FALSE, "Path not relative? (%s)\n", wine_dbgstr_w(Buf));
|
||||
ok(bRelative == FALSE, "Path not absolute? (%s)\n", wine_dbgstr_w(Buf));
|
||||
ok(Ptr != (Buf + wcslen(Buf)), "Did not find a separator in '%s'!\n", wine_dbgstr_w(Buf));
|
||||
|
||||
// Expected 'arial.ttf' (2k3), 'Arial' (Vista) or 'System Bold' (7+), 'System \0388\03bd\03c4\03bf\03bd\03b7 \03b3\03c1\03b1\03c6\03ae' in greek
|
||||
if (FAILED(GetDisplayName(spFolder, fontPidl, SHGDN_INFOLDER, Buf)))
|
||||
return;
|
||||
|
||||
bRelative = PathIsRelativeW(Buf);
|
||||
Ptr = PathFindNextComponentW(Buf);
|
||||
trace("Path: %s\n", wine_dbgstr_w(Buf));
|
||||
ok(bRelative != FALSE, "Path not relative? (%s)\n", wine_dbgstr_w(Buf));
|
||||
ok(Ptr == (Buf + wcslen(Buf)), "Found a separator in '%s'!\n", wine_dbgstr_w(Buf));
|
||||
|
||||
// Expected 'arial.ttf' (2k3) or 'Arial' (Vista), 'System Bold' (7+), 'System \0388\03bd\03c4\03bf\03bd\03b7 \03b3\03c1\03b1\03c6\03ae' in greek
|
||||
if (FAILED(GetDisplayName(spFolder, fontPidl, SHGDN_NORMAL, Buf)))
|
||||
return;
|
||||
|
||||
bRelative = PathIsRelativeW(Buf);
|
||||
Ptr = PathFindNextComponentW(Buf);
|
||||
trace("Path: %s\n", wine_dbgstr_w(Buf));
|
||||
ok(bRelative != FALSE, "Path not relative? (%s)\n", wine_dbgstr_w(Buf));
|
||||
ok(Ptr == (Buf + wcslen(Buf)), "Found a separator in '%s'!\n", wine_dbgstr_w(Buf));
|
||||
|
||||
// Expected 'arial.ttf' (2k3), 'C:\\WINDOWS\\Fonts\\arial.ttf' (Vista), 'System Bold' (7+)
|
||||
if (FAILED(GetDisplayName(spFolder, fontPidl, SHGDN_INFOLDER | SHGDN_FORPARSING, Buf)))
|
||||
return;
|
||||
|
||||
bRelative = PathIsRelativeW(Buf);
|
||||
Ptr = PathFindNextComponentW(Buf);
|
||||
trace("Path: %s\n", wine_dbgstr_w(Buf));
|
||||
if (g_bVistaWorkaround)
|
||||
{
|
||||
// Vista is the odd one here
|
||||
ok(bRelative == FALSE, "Path not absolute? (%s)\n", wine_dbgstr_w(Buf));
|
||||
ok(Ptr != (Buf + wcslen(Buf)), "Did not find a separator in '%s'!\n", wine_dbgstr_w(Buf));
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(bRelative != FALSE, "Path not relative? (%s)\n", wine_dbgstr_w(Buf));
|
||||
ok(Ptr == (Buf + wcslen(Buf)), "Found a separator in '%s'!\n", wine_dbgstr_w(Buf));
|
||||
}
|
||||
|
||||
// Expected 'arial.ttf' (2k3), 'Arial' (Vista) or 'Fonts\\System Bold' (7+), 'Fonts\\System \0388\03bd\03c4\03bf\03bd\03b7 \03b3\03c1\03b1\03c6\03ae' in greek
|
||||
if (FAILED(GetDisplayName(spFolder, fontPidl, SHGDN_FORADDRESSBAR, Buf)))
|
||||
return;
|
||||
|
||||
bRelative = PathIsRelativeW(Buf);
|
||||
Ptr = PathFindNextComponentW(Buf);
|
||||
trace("Path: %s\n", wine_dbgstr_w(Buf));
|
||||
ok(bRelative != FALSE, "Path not relative? (%s)\n", wine_dbgstr_w(Buf));
|
||||
|
||||
// 2k3 does not have a custom IShellFolder, so there this weird behavior does not exist:
|
||||
// (And vista's version is ???)
|
||||
if (g_bFontFolderWithShellView || g_bVistaWorkaround)
|
||||
{
|
||||
ok(Ptr == (Buf + wcslen(Buf)), "Found a separator in '%s'!\n", wine_dbgstr_w(Buf));
|
||||
}
|
||||
else
|
||||
{
|
||||
// For some reason, there is 'Fonts\\' in front of the fontname...
|
||||
ok(Ptr != (Buf + wcslen(Buf)), "Did not find a separator in '%s'!\n", wine_dbgstr_w(Buf));
|
||||
ok(!_wcsnicmp(FolderName, Buf, wcslen(FolderName)), "Result (%s) does not start with fonts folder (%s)\n",
|
||||
wine_dbgstr_w(Buf), wine_dbgstr_w(FolderName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,12 +173,24 @@ START_TEST(GetDisplayNameOf)
|
|||
{
|
||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
|
||||
// Detect if this is an old (2k3) style fontext, or a new one.
|
||||
// The old one has an IShellView, the new one an IShellFolder
|
||||
{
|
||||
CComPtr<IShellView> spView;
|
||||
HRESULT hr = CoCreateInstance(CLSID_FontExt, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellView, &spView));
|
||||
g_bFontFolderWithShellView = SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
g_bVistaWorkaround = IsWindowsVistaOrGreater() && !IsWindows7OrGreater();
|
||||
|
||||
trace("Has shellview: %d, Vista: %d\n", g_bFontFolderWithShellView, g_bVistaWorkaround);
|
||||
{
|
||||
CComPtr<IShellFolder> spFolder;
|
||||
HRESULT hr = Initialize(spFolder);
|
||||
WCHAR FolderName[MAX_PATH];
|
||||
HRESULT hr = Initialize(spFolder, FolderName);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
Test_GetDisplayNameOf(spFolder);
|
||||
Test_GetDisplayNameOf(spFolder, FolderName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <shellutils.h>
|
||||
#include "wine/test.h"
|
||||
|
||||
const CLSID CLSID_FontExt = { 0xBD84B380, 0x8CA2, 0x1069, { 0xAB, 0x1D, 0x08, 0x00, 0x09, 0x48, 0xF5, 0x34 } };
|
||||
static const CLSID CLSID_FontExt = { 0xBD84B380, 0x8CA2, 0x1069, { 0xAB, 0x1D, 0x08, 0x00, 0x09, 0x48, 0xF5, 0x34 } };
|
||||
static DWORD g_WinVersion;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue