mirror of
https://github.com/reactos/reactos.git
synced 2024-11-04 22:00:55 +00:00
[ZIPFLDR_APITEST] Fix the test on 2k3, where a zip folder is marked as 'file', not as 'folder'
This commit is contained in:
parent
64527aa948
commit
c7b83d2ce4
1 changed files with 45 additions and 85 deletions
|
@ -2,7 +2,7 @@
|
||||||
* PROJECT: ReactOS api tests
|
* PROJECT: ReactOS api tests
|
||||||
* 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: Test the result of enumerating over a folder with a zip in it
|
* PURPOSE: Test the result of enumerating over a folder with a zip in it
|
||||||
* COPYRIGHT: Copyright 2020 Mark Jansen (mark.jansen@reactos.org)
|
* COPYRIGHT: Copyright 2020-2023 Mark Jansen (mark.jansen@reactos.org)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
@ -50,31 +50,37 @@ void FindExpectedFile(FileInfo* Array, size_t len, IShellFolder* pFolder, PCUITE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_EnumDirFiles(const WCHAR* TestFolder)
|
const SFGAOF BaseFileAttributes = SFGAO_FILESYSTEM;
|
||||||
|
const SFGAOF BaseFolderAttributes = SFGAO_FILESYSTEM | SFGAO_FOLDER;
|
||||||
|
FileInfo ExpectedFiles[] = {
|
||||||
|
{ L"test.txt", BaseFileAttributes, false },
|
||||||
|
{ L"TMP0.zip", BaseFileAttributes, false}, // 2k3 Shows this as a file, newer shows this as a folder
|
||||||
|
{ L"ASUBFLD", BaseFolderAttributes | SFGAO_FILESYSANCESTOR | SFGAO_STORAGEANCESTOR, false },
|
||||||
|
};
|
||||||
|
BOOL FoundZipfldr = FALSE;
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_EnumDirFiles(const WCHAR *TestFolder, BOOL EnumFolders)
|
||||||
{
|
{
|
||||||
CComPtr<IShellFolder> spFolder;
|
CComPtr<IShellFolder> spFolder;
|
||||||
if (!InitializeShellFolder(TestFolder, spFolder))
|
if (!InitializeShellFolder(TestFolder, spFolder))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CComPtr<IEnumIDList> spEnum;
|
CComPtr<IEnumIDList> spEnum;
|
||||||
ok_int(zipfldr_loaded(), FALSE);
|
ok_int(zipfldr_loaded(), FoundZipfldr);
|
||||||
HRESULT hr = spFolder->EnumObjects(NULL, SHCONTF_NONFOLDERS, &spEnum);
|
HRESULT hr = spFolder->EnumObjects(NULL, EnumFolders ? SHCONTF_FOLDERS : SHCONTF_NONFOLDERS, &spEnum);
|
||||||
ok_hr(hr, S_OK);
|
ok_hr(hr, S_OK);
|
||||||
if (!SUCCEEDED(hr))
|
if (!SUCCEEDED(hr))
|
||||||
return;
|
return;
|
||||||
ok_int(zipfldr_loaded(), FALSE);
|
ok_int(zipfldr_loaded(), FoundZipfldr);
|
||||||
|
|
||||||
SFGAOF BaseAttributes = SFGAO_FILESYSTEM;
|
|
||||||
FileInfo ExpectedFiles[] = {
|
|
||||||
{ L"test.txt", BaseAttributes, false },
|
|
||||||
};
|
|
||||||
|
|
||||||
ULONG totalFetched = 0;
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CComHeapPtr<ITEMID_CHILD> child;
|
CComHeapPtr<ITEMID_CHILD> child;
|
||||||
ULONG celtFetched = 0;
|
ULONG celtFetched = 0;
|
||||||
|
ok_int(zipfldr_loaded(), FoundZipfldr);
|
||||||
hr = spEnum->Next(1, &child, &celtFetched);
|
hr = spEnum->Next(1, &child, &celtFetched);
|
||||||
|
ok_int(zipfldr_loaded(), FoundZipfldr);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
break;
|
break;
|
||||||
ok_int(celtFetched, 1);
|
ok_int(celtFetched, 1);
|
||||||
|
@ -85,89 +91,32 @@ static void test_EnumDirFiles(const WCHAR* TestFolder)
|
||||||
SFGAOF ExpectedAttributes;
|
SFGAOF ExpectedAttributes;
|
||||||
FindExpectedFile(ExpectedFiles, RTL_NUMBER_OF(ExpectedFiles), spFolder, child, ExpectedName, ExpectedAttributes);
|
FindExpectedFile(ExpectedFiles, RTL_NUMBER_OF(ExpectedFiles), spFolder, child, ExpectedName, ExpectedAttributes);
|
||||||
|
|
||||||
totalFetched++;
|
ok_int(zipfldr_loaded(), FoundZipfldr);
|
||||||
|
|
||||||
ok_displayname(spFolder, child, SHGDN_NORMAL, ExpectedName);
|
ok_displayname(spFolder, child, SHGDN_NORMAL, ExpectedName);
|
||||||
|
ok_int(zipfldr_loaded(), FoundZipfldr);
|
||||||
|
|
||||||
SFGAOF Attributes = SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER;
|
SFGAOF Attributes = SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER;
|
||||||
hr = spFolder->GetAttributesOf(1, &child, &Attributes);
|
hr = spFolder->GetAttributesOf(1, &child, &Attributes);
|
||||||
|
|
||||||
|
if (!wcsicmp(ExpectedName, L"TMP0.zip"))
|
||||||
|
{
|
||||||
|
// We allow both .zip files being a 'file' (2k3) or a 'folder' (win10)
|
||||||
|
if (Attributes & SFGAO_FOLDER)
|
||||||
|
ExpectedAttributes |= SFGAO_FOLDER;
|
||||||
|
// Only at this point (after calling GetAttributesOf) it will load zipfldr
|
||||||
|
FoundZipfldr = TRUE;
|
||||||
|
trace("Found zip (%S)\n", ExpectedName);
|
||||||
|
}
|
||||||
|
ok_int(zipfldr_loaded(), FoundZipfldr);
|
||||||
|
|
||||||
/* Just keep the ones we are interested in */
|
/* Just keep the ones we are interested in */
|
||||||
Attributes &= (SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR | SFGAO_STORAGEANCESTOR);
|
Attributes &= (SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR | SFGAO_STORAGEANCESTOR);
|
||||||
ok_hr(hr, S_OK);
|
ok_hr(hr, S_OK);
|
||||||
ok_hex(Attributes, ExpectedAttributes);
|
ok_hex(Attributes, ExpectedAttributes);
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
ok_int(totalFetched, RTL_NUMBER_OF(ExpectedFiles));
|
|
||||||
ok_hr(hr, S_FALSE);
|
|
||||||
ok_int(zipfldr_loaded(), FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_EnumDirDirs(const WCHAR* TestFolder)
|
|
||||||
{
|
|
||||||
CComPtr<IShellFolder> spFolder;
|
|
||||||
if (!InitializeShellFolder(TestFolder, spFolder))
|
|
||||||
return;
|
|
||||||
|
|
||||||
CComPtr<IEnumIDList> spEnum;
|
|
||||||
ok_int(zipfldr_loaded(), FALSE);
|
|
||||||
HRESULT hr = spFolder->EnumObjects(NULL, SHCONTF_FOLDERS, &spEnum);
|
|
||||||
ok_hr(hr, S_OK);
|
|
||||||
if (!SUCCEEDED(hr))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ok_int(zipfldr_loaded(), FALSE);
|
|
||||||
|
|
||||||
SFGAOF BaseAttributes = SFGAO_FILESYSTEM | SFGAO_FOLDER;
|
|
||||||
FileInfo ExpectedFiles[] = {
|
|
||||||
{ L"TMP0.zip", BaseAttributes, false},
|
|
||||||
{ L"ASUBFLD", BaseAttributes | SFGAO_FILESYSANCESTOR | SFGAO_STORAGEANCESTOR, false },
|
|
||||||
};
|
|
||||||
|
|
||||||
bool bFoundZipfldr = false;
|
|
||||||
|
|
||||||
ULONG totalFetched = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
CComHeapPtr<ITEMID_CHILD> child;
|
|
||||||
ULONG celtFetched = 0;
|
|
||||||
ok_int(zipfldr_loaded(), bFoundZipfldr ? TRUE : FALSE);
|
|
||||||
hr = spEnum->Next(1, &child, &celtFetched);
|
|
||||||
if (hr != S_OK)
|
|
||||||
break;
|
|
||||||
ok_int(celtFetched, 1);
|
|
||||||
if (celtFetched != 1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
ok_int(zipfldr_loaded(), bFoundZipfldr ? TRUE : FALSE);
|
|
||||||
|
|
||||||
LPCWSTR ExpectedName;
|
|
||||||
SFGAOF ExpectedAttributes;
|
|
||||||
FindExpectedFile(ExpectedFiles, RTL_NUMBER_OF(ExpectedFiles), spFolder, child, ExpectedName, ExpectedAttributes);
|
|
||||||
|
|
||||||
totalFetched++;
|
|
||||||
|
|
||||||
ok_displayname(spFolder, child, SHGDN_NORMAL, ExpectedName);
|
|
||||||
trace("Current: %S\n", ExpectedName);
|
|
||||||
|
|
||||||
SFGAOF Attributes = SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER;
|
|
||||||
hr = spFolder->GetAttributesOf(1, &child, &Attributes);
|
|
||||||
if ((ExpectedAttributes & SFGAO_FILESYSANCESTOR))
|
|
||||||
{
|
|
||||||
ok_int(zipfldr_loaded(), bFoundZipfldr ? TRUE : FALSE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ok_int(zipfldr_loaded(), TRUE);
|
|
||||||
bFoundZipfldr = true;
|
|
||||||
}
|
|
||||||
/* Just keep the ones we are interested in */
|
|
||||||
Attributes &= (SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR | SFGAO_STORAGEANCESTOR);
|
|
||||||
ok_hr(hr, S_OK);
|
|
||||||
ok_hex(Attributes, ExpectedAttributes);
|
|
||||||
} while (true);
|
|
||||||
|
|
||||||
ok_int(totalFetched, RTL_NUMBER_OF(ExpectedFiles));
|
|
||||||
ok_hr(hr, S_FALSE);
|
ok_hr(hr, S_FALSE);
|
||||||
|
ok_int(zipfldr_loaded(), FoundZipfldr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,6 +128,8 @@ START_TEST(EnumParentDir)
|
||||||
if (!SUCCEEDED(hr))
|
if (!SUCCEEDED(hr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ok_int(zipfldr_loaded(), FALSE);
|
||||||
|
|
||||||
WCHAR TestFolder[MAX_PATH], TestFile[MAX_PATH], SubFolder[MAX_PATH];
|
WCHAR TestFolder[MAX_PATH], TestFile[MAX_PATH], SubFolder[MAX_PATH];
|
||||||
GetTempPathW(_countof(TestFolder), TestFolder);
|
GetTempPathW(_countof(TestFolder), TestFolder);
|
||||||
PathAppendW(TestFolder, L"ZipDir");
|
PathAppendW(TestFolder, L"ZipDir");
|
||||||
|
@ -204,8 +155,17 @@ START_TEST(EnumParentDir)
|
||||||
|
|
||||||
CreateDirectoryW(SubFolder, NULL);
|
CreateDirectoryW(SubFolder, NULL);
|
||||||
|
|
||||||
test_EnumDirFiles(TestFolder);
|
winetest_push_context("Files");
|
||||||
test_EnumDirDirs(TestFolder);
|
test_EnumDirFiles(TestFolder, FALSE);
|
||||||
|
winetest_pop_context();
|
||||||
|
winetest_push_context("Folders");
|
||||||
|
test_EnumDirFiles(TestFolder, TRUE);
|
||||||
|
winetest_pop_context();
|
||||||
|
|
||||||
|
for (size_t n = 0; n < RTL_NUMBER_OF(ExpectedFiles); ++n)
|
||||||
|
{
|
||||||
|
ok(ExpectedFiles[n].Found, "Did not find %S\n", ExpectedFiles[n].Name);
|
||||||
|
}
|
||||||
|
|
||||||
RemoveDirectoryW(SubFolder);
|
RemoveDirectoryW(SubFolder);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue