shell32/tests: Tests for broken apps that check GetLastError() after SHFileOperation().
Signed-off-by: Olivier F. R. Dierick <o.dierick@piezo-forte.be> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
9f202b7804
commit
07156ad007
|
@ -1819,6 +1819,30 @@ static void test_copy(void)
|
|||
ok(DeleteFileA("abcdefgh.abc"), "Expected file to exist\n");
|
||||
ok(DeleteFileA("dir\\abcdefgh.abc"), "Expected file to exist\n");
|
||||
ok(RemoveDirectoryA("dir"), "Expected dir to exist\n");
|
||||
|
||||
/* Check last error after a successful file operation. */
|
||||
clean_after_shfo_tests();
|
||||
init_shfo_tests();
|
||||
shfo.pFrom = "test1.txt\0";
|
||||
shfo.pTo = "testdir2\0";
|
||||
shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
|
||||
SetLastError(0xdeadbeef);
|
||||
retval = SHFileOperationA(&shfo);
|
||||
ok(retval == ERROR_SUCCESS, "File copy failed with %d\n", retval);
|
||||
ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
|
||||
|
||||
/* Check last error after a failed file operation. */
|
||||
clean_after_shfo_tests();
|
||||
init_shfo_tests();
|
||||
shfo.pFrom = "nonexistent\0";
|
||||
shfo.pTo = "testdir2\0";
|
||||
shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
|
||||
SetLastError(0xdeadbeef);
|
||||
retval = SHFileOperationA(&shfo);
|
||||
ok(retval != ERROR_SUCCESS, "Unexpected ERROR_SUCCESS\n");
|
||||
ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
|
||||
}
|
||||
|
||||
/* tests the FO_MOVE action */
|
||||
|
@ -2464,6 +2488,7 @@ static void test_unicode(void)
|
|||
SHFILEOPSTRUCTW shfoW;
|
||||
int ret;
|
||||
HANDLE file;
|
||||
static const WCHAR UNICODE_PATH_TO[] = {'c',':','\\',0x00ae,0x00ae,'\0'};
|
||||
|
||||
if (!pSHFileOperationW)
|
||||
{
|
||||
|
@ -2530,6 +2555,36 @@ static void test_unicode(void)
|
|||
ret = pSHFileOperationW(&shfoW);
|
||||
ok(!ret, "Directory is not removed, ErrorCode: %d\n", ret);
|
||||
ok(!file_existsW(UNICODE_PATH), "The directory should have been removed\n");
|
||||
|
||||
shfoW.hwnd = NULL;
|
||||
shfoW.wFunc = FO_COPY;
|
||||
shfoW.pFrom = UNICODE_PATH;
|
||||
shfoW.pTo = UNICODE_PATH_TO;
|
||||
shfoW.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
|
||||
shfoW.hNameMappings = NULL;
|
||||
shfoW.lpszProgressTitle = NULL;
|
||||
|
||||
/* Check last error after a successful file operation. */
|
||||
createTestFileW(UNICODE_PATH);
|
||||
ok(file_existsW(UNICODE_PATH), "The file does not exist\n");
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = SHFileOperationW(&shfoW);
|
||||
ok(ret == ERROR_SUCCESS, "File copy failed with %d\n", ret);
|
||||
ok(!shfoW.fAnyOperationsAborted, "Didn't expect aborted operations\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS ||
|
||||
broken(GetLastError() == ERROR_INVALID_HANDLE), /* WinXp, win2k3 */
|
||||
"Expected ERROR_SUCCESS, got %d\n", GetLastError());
|
||||
|
||||
/* Check last error after a failed file operation. */
|
||||
DeleteFileW(UNICODE_PATH);
|
||||
ok(!file_existsW(UNICODE_PATH), "The file should have been removed\n");
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = SHFileOperationW(&shfoW);
|
||||
ok(ret != ERROR_SUCCESS, "Unexpected ERROR_SUCCESS\n");
|
||||
ok(!shfoW.fAnyOperationsAborted, "Didn't expect aborted operations\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS ||
|
||||
broken(GetLastError() == ERROR_INVALID_HANDLE), /* WinXp, win2k3 */
|
||||
"Expected ERROR_SUCCESS, got %d\n", GetLastError());
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue