Commit 07156ad0 authored by Olivier F. R. Dierick's avatar Olivier F. R. Dierick Committed by Alexandre Julliard

shell32/tests: Tests for broken apps that check GetLastError() after SHFileOperation().

parent 9f202b78
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment