https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e771589ae1df303b76ab9…
commit e771589ae1df303b76ab93b88ada0dd9e7fb27ae
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sat Apr 3 16:56:49 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sat Apr 3 16:56:49 2021 +0900
[BROWSEUI_APITEST] Strengthen ACListISF testcase (#3577)
Analyze CLSID_ACListISF's behavior about relative paths. CORE-9281
---
modules/rostests/apitests/browseui/ACListISF.cpp | 197 ++++++++++++++++++++---
1 file changed, 179 insertions(+), 18 deletions(-)
diff --git a/modules/rostests/apitests/browseui/ACListISF.cpp
b/modules/rostests/apitests/browseui/ACListISF.cpp
index 7cb1bc6d93a..ab87cb492ef 100644
--- a/modules/rostests/apitests/browseui/ACListISF.cpp
+++ b/modules/rostests/apitests/browseui/ACListISF.cpp
@@ -41,9 +41,6 @@ static DWORD g_WinVersion;
#expression, (int)(expected), _value); \
} while (0)
-
-
-
static void test_at_end_imp(CComPtr<IEnumString>& EnumStr)
{
CComHeapPtr<OLECHAR> Result;
@@ -128,11 +125,9 @@ test_ExpectFolders_imp(CComPtr<IEnumString>& EnumStr,
LPITEMIDLIST pidlTarget, c
hr = EnumStr->Next(1, &Result, &Fetched);
winetest_ok_hr(hr, S_OK);
-
if (hr != S_OK)
break;
-
StringCchPrintfW(Buffer, _ARRAYSIZE(Buffer), L"%s%s", (options &
IgnoreRoot) ? L"" : Root, (WCHAR*)DisplayName);
winetest_ok(!wcscmp(Buffer, Result), "Expected %s, got %s\n",
wine_dbgstr_w(Buffer), wine_dbgstr_w(Result));
@@ -159,12 +154,18 @@ test_ACListISF_NONE()
HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL,
IID_PPV_ARG(IEnumString, &EnumStr));
ok_hr(hr, S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("CoCreateInstance failed\n");
return;
+ }
CComPtr<IACList2> ACList;
ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("QueryInterface failed\n");
return;
+ }
ok_hr(hr = ACList->SetOptions(ACLO_NONE), S_OK);
test_at_end(EnumStr);
@@ -177,7 +178,10 @@ test_ACListISF_NONE()
CComHeapPtr<ITEMIDLIST> pidlDiskRoot;
ok_hr(hr = SHParseDisplayName(Buffer, NULL, &pidlDiskRoot, NULL, NULL), S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("SHParseDisplayName failed\n");
return;
+ }
ok_hr(hr = ACList->Expand(Buffer), S_OK);
test_ExpectFolders(EnumStr, pidlDiskRoot, Buffer, CheckLast | IgnoreHidden);
@@ -195,17 +199,26 @@ test_ACListISF_CURRENTDIR()
HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL,
IID_PPV_ARG(IEnumString, &EnumStr));
ok_hr(hr, S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("CoCreateInstance failed\n");
return;
+ }
CComPtr<IACList2> ACList;
ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("QueryInterface failed\n");
return;
+ }
CComPtr<ICurrentWorkingDirectory> CurrentWorkingDir;
ok_hr(hr = EnumStr->QueryInterface(IID_ICurrentWorkingDirectory,
(void**)&CurrentWorkingDir), S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("QueryInterface failed\n");
return;
+ }
ok_hr(hr = ACList->SetOptions(ACLO_CURRENTDIR), S_OK);
test_at_end(EnumStr);
@@ -325,18 +338,10 @@ test_ACListISF_CURRENTDIR()
ok_wstr(psz, L"tes2");
CoTaskMemFree(psz);
- hr = EnumStr->Next(1, &psz, &cGot);
- ok_hr(hr, S_FALSE);
- CoTaskMemFree(psz);
-
StringCbCopyW(szPath, sizeof(szPath), szDir);
StringCbCatW(szPath, sizeof(szPath), L"\\BROWSEUI-2");
ok_hr(hr = CurrentWorkingDir->SetDirectory(szPath), S_OK);
- hr = EnumStr->Next(1, &psz, &cGot);
- ok_hr(hr, S_FALSE);
- CoTaskMemFree(psz);
-
EnumStr->Reset();
hr = EnumStr->Next(1, &psz, &cGot);
@@ -349,10 +354,6 @@ test_ACListISF_CURRENTDIR()
ok_wstr(psz, L"tes2");
CoTaskMemFree(psz);
- hr = EnumStr->Next(1, &psz, &cGot);
- ok_hr(hr, S_FALSE);
- CoTaskMemFree(psz);
-
StringCbCopyW(szPath, sizeof(szPath), szDir);
StringCbCatW(szPath, sizeof(szPath), L"\\BROWSEUI-1\\TEST1");
RemoveDirectoryW(szPath);
@@ -378,6 +379,121 @@ test_ACListISF_CURRENTDIR()
RemoveDirectoryW(szPath);
}
+static void
+test_ACListISF_CURRENTDIR2()
+{
+ CComPtr<IEnumString> EnumStr;
+ HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL,
IID_PPV_ARG(IEnumString, &EnumStr));
+ ok_hr(hr, S_OK);
+ if (!SUCCEEDED(hr))
+ {
+ skip("CoCreateInstance failed\n");
+ return;
+ }
+
+ CComPtr<IACList2> ACList;
+ ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
+ if (!SUCCEEDED(hr))
+ {
+ skip("QueryInterface failed\n");
+ return;
+ }
+
+ CComPtr<ICurrentWorkingDirectory> CurrentWorkingDir;
+ ok_hr(hr = EnumStr->QueryInterface(IID_ICurrentWorkingDirectory,
(void**)&CurrentWorkingDir), S_OK);
+ if (!SUCCEEDED(hr))
+ {
+ skip("QueryInterface failed\n");
+ return;
+ }
+
+ ok_hr(hr = ACList->SetOptions(ACLO_CURRENTDIR), S_OK);
+ test_at_end(EnumStr);
+
+ CreateDirectoryW(L"C:\\BROWSEUI-1", NULL);
+ CreateDirectoryW(L"C:\\BROWSEUI-1\\TEST1", NULL);
+ CreateDirectoryW(L"C:\\BROWSEUI-1\\TEST2", NULL);
+ CreateDirectoryW(L"C:\\BROWSEUI-1\\TEST1\\TEST3", NULL);
+ CreateDirectoryW(L"C:\\BROWSEUI-2", NULL);
+ CreateDirectoryW(L"C:\\BROWSEUI-2\\TEST1", NULL);
+ CreateDirectoryW(L"C:\\BROWSEUI-2\\TEST2", NULL);
+ CreateDirectoryW(L"C:\\BROWSEUI-2\\TEST1\\TEST4", NULL);
+
+ ok_hr(hr = CurrentWorkingDir->SetDirectory(L"C:\\BROWSEUI-1\\TEST1"),
S_OK);
+ test_at_end(EnumStr);
+
+ ok_hr(hr = ACList->Expand(L"C:\\BROWSEUI-2\\TEST1\\"), S_OK);
+
+ LPWSTR psz;
+ ULONG cGot;
+
+ hr = EnumStr->Next(1, &psz, &cGot);
+ ok_hr(hr, S_OK);
+ ok_wstr(psz, L"C:\\BROWSEUI-2\\TEST1\\TEST4");
+ CoTaskMemFree(psz);
+
+ hr = EnumStr->Next(1, &psz, &cGot);
+ ok_hr(hr, S_OK);
+ ok_wstr(psz, L"TEST3");
+ CoTaskMemFree(psz);
+
+ test_at_end(EnumStr);
+
+ ok_hr(hr = ACList->Expand(L"C:\\BROWSEUI-1\\TEST1\\"), S_OK);
+
+ hr = EnumStr->Next(1, &psz, &cGot);
+ ok_hr(hr, S_OK);
+ ok_wstr(psz, L"C:\\BROWSEUI-1\\TEST1\\TEST3");
+ CoTaskMemFree(psz);
+
+ hr = EnumStr->Next(1, &psz, &cGot);
+ ok_hr(hr, S_OK);
+ ok_wstr(psz, L"TEST3");
+ CoTaskMemFree(psz);
+
+ test_at_end(EnumStr);
+
+ ok_hr(hr = CurrentWorkingDir->SetDirectory(L"C:\\BROWSEUI-2\\TEST1"),
S_OK);
+ test_at_end(EnumStr);
+
+ ok_hr(hr = ACList->Expand(L"..\\TEST1\\"), S_OK);
+
+ hr = EnumStr->Next(1, &psz, &cGot);
+ ok_hr(hr, S_OK);
+ ok_wstr(psz, L"..\\TEST1\\TEST4");
+ CoTaskMemFree(psz);
+
+ hr = EnumStr->Next(1, &psz, &cGot);
+ ok_hr(hr, S_OK);
+ ok_wstr(psz, L"TEST4");
+ CoTaskMemFree(psz);
+
+ test_at_end(EnumStr);
+
+ ok_hr(hr = ACList->Expand(L"\\BROWSEUI-2\\TEST1\\"), S_OK);
+
+ hr = EnumStr->Next(1, &psz, &cGot);
+ ok_hr(hr, S_OK);
+ ok_wstr(psz, L"\\BROWSEUI-2\\TEST1\\TEST4");
+ CoTaskMemFree(psz);
+
+ hr = EnumStr->Next(1, &psz, &cGot);
+ ok_hr(hr, S_OK);
+ ok_wstr(psz, L"TEST4");
+ CoTaskMemFree(psz);
+
+ test_at_end(EnumStr);
+
+ RemoveDirectoryW(L"C:\\BROWSEUI-1\\TEST1\\TEST3");
+ RemoveDirectoryW(L"C:\\BROWSEUI-1\\TEST1");
+ RemoveDirectoryW(L"C:\\BROWSEUI-1\\TEST2");
+ RemoveDirectoryW(L"C:\\BROWSEUI-1");
+ RemoveDirectoryW(L"C:\\BROWSEUI-2\\TEST1\\TEST4");
+ RemoveDirectoryW(L"C:\\BROWSEUI-2\\TEST1");
+ RemoveDirectoryW(L"C:\\BROWSEUI-2\\TEST2");
+ RemoveDirectoryW(L"C:\\BROWSEUI-2");
+}
+
static void
test_ACListISF_MYCOMPUTER()
{
@@ -385,7 +501,10 @@ test_ACListISF_MYCOMPUTER()
HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL,
IID_PPV_ARG(IACList2, &ACList));
ok_hr(hr, S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("CoCreateInstance failed\n");
return;
+ }
// Check the default
DWORD CurrentOption = 0xdeadbeef;
@@ -397,18 +516,26 @@ test_ACListISF_MYCOMPUTER()
CComPtr<IEnumString> EnumStr;
ok_hr(hr = ACList->QueryInterface(IID_IEnumString, (void**)&EnumStr), S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("QueryInterface failed\n");
return;
+ }
CComPtr<IPersistFolder> PersistFolder;
ok_hr(hr = EnumStr->QueryInterface(IID_IPersistFolder,
(void**)&PersistFolder), S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("QueryInterface failed\n");
return;
+ }
CComHeapPtr<ITEMIDLIST> pidlMyComputer;
ok_hr(hr = SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlMyComputer),
S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("SHGetSpecialFolderLocation failed\n");
return;
-
+ }
hr = EnumStr->Reset();
if (g_WinVersion < WINVER_VISTA)
@@ -455,12 +582,18 @@ test_ACListISF_DESKTOP()
HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL,
IID_PPV_ARG(IEnumString, &EnumStr));
ok_hr(hr, S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("CoCreateInstance failed\n");
return;
+ }
CComPtr<IACList2> ACList;
ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("QueryInterface failed\n");
return;
+ }
ok_hr(hr = ACList->SetOptions(ACLO_DESKTOP), S_OK);
test_ExpectFolders(EnumStr, NULL, NULL, IgnoreRoot | CheckLast | IgnoreHidden);
@@ -473,17 +606,26 @@ test_ACListISF_FAVORITES()
HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL,
IID_PPV_ARG(IEnumString, &EnumStr));
ok_hr(hr, S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("CoCreateInstance failed\n");
return;
+ }
CComPtr<IACList2> ACList;
ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("QueryInterface failed\n");
return;
+ }
CComHeapPtr<ITEMIDLIST> pidlFavorites;
ok_hr(hr = SHGetSpecialFolderLocation(NULL, CSIDL_FAVORITES, &pidlFavorites),
S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("SHGetSpecialFolderLocation failed\n");
return;
+ }
ok_hr(hr = ACList->SetOptions(ACLO_FAVORITES), S_OK);
test_ExpectFolders(EnumStr, pidlFavorites, NULL, IgnoreRoot | CheckLast |
IgnoreHidden);
@@ -496,12 +638,18 @@ test_ACListISF_FILESYSONLY()
HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL,
IID_PPV_ARG(IEnumString, &EnumStr));
ok_hr(hr, S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("CoCreateInstance failed\n");
return;
+ }
CComPtr<IACList2> ACList;
ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("QueryInterface failed\n");
return;
+ }
WCHAR Buffer[MAX_PATH];
GetSystemWindowsDirectoryW(Buffer, _ARRAYSIZE(Buffer));
@@ -510,7 +658,10 @@ test_ACListISF_FILESYSONLY()
CComHeapPtr<ITEMIDLIST> pidlDiskRoot;
ok_hr(hr = SHParseDisplayName(Buffer, NULL, &pidlDiskRoot, NULL, NULL), S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("SHParseDisplayName failed\n");
return;
+ }
ok_hr(hr = ACList->SetOptions(ACLO_FILESYSONLY), S_OK);
test_at_end(EnumStr);
@@ -526,12 +677,18 @@ test_ACListISF_FILESYSDIRS()
HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL,
IID_PPV_ARG(IEnumString, &EnumStr));
ok_hr(hr, S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("CoCreateInstance failed\n");
return;
+ }
CComPtr<IACList2> ACList;
ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
if (!SUCCEEDED(hr))
+ {
+ skip("QueryInterface failed\n");
return;
+ }
WCHAR Buffer[MAX_PATH];
GetSystemWindowsDirectoryW(Buffer, _ARRAYSIZE(Buffer));
@@ -578,10 +735,14 @@ START_TEST(ACListISF)
CCoInit init;
ok_hr(init.hres, S_OK);
if (!SUCCEEDED(init.hres))
+ {
+ skip("CoInitialize failed\n");
return;
+ }
test_ACListISF_NONE();
test_ACListISF_CURRENTDIR();
+ test_ACListISF_CURRENTDIR2();
test_ACListISF_MYCOMPUTER();
test_ACListISF_DESKTOP();
test_ACListISF_FAVORITES();