Olivier F. R. Dierick : shell32/tests: Tests for broken apps that check GetLastError() after SHFileOperation().
Alexandre Julliard
julliard at wine.codeweavers.com
Mon May 2 09:52:31 CDT 2016
Module: wine
Branch: master
Commit: 07156ad007dead9b8eb535c8c76969fe6a427ea4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=07156ad007dead9b8eb535c8c76969fe6a427ea4
Author: Olivier F. R. Dierick <o.dierick at piezo-forte.be>
Date: Sat Apr 23 16:04:01 2016 +0200
shell32/tests: Tests for broken apps that check GetLastError() after SHFileOperation().
Signed-off-by: Olivier F. R. Dierick <o.dierick at piezo-forte.be>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/shell32/tests/shlfileop.c | 55 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c
index d33ad5b..0e502fc 100644
--- a/dlls/shell32/tests/shlfileop.c
+++ b/dlls/shell32/tests/shlfileop.c
@@ -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
More information about the wine-cvs
mailing list