---
������dlls/kernel32/tests/file.c | 107 +++++++++++++++++++++++++++++++++++++++++++++
������1 file changed, 107 insertions(+)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
index 410c3f0591..43b9143322 100644
--- a/dlls/kernel32/tests/file.c
+++ b/dlls/kernel32/tests/file.c
@@ -4964,6 +4964,112 @@ static void test_GetFileAttributesExW(void)
������ ������ ������ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected error ERROR_FILE_NOT_FOUND, got %u\n", GetLastError());
������}
������
+// constant defined in path.c, CopyFileExW()
+#define MFWP_CopyFileExW_BufferLength������ ������65536
+#define MFWP_MB������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������128������ ������ ������// 128 MB file
+#define MFWP_Kilo������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������1024
+#define MFWP_ExpectedChunks������ ������ ������ ������ ������ ������ ������((MFWP_MB*MFWP_Kilo*MFWP_Kilo)/MFWP_CopyFileExW_BufferLength)
+static int test_MFWPChunks = 0;
+static int test_MFWPFailTest = 0;
+DWORD CALLBACK test_MoveFileWithProgressWCB(LARGE_INTEGER TotalFileSize,
+������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ LARGE_INTEGER TotalBytesTransferred,
+������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ LARGE_INTEGER StreamSize,
+������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ LARGE_INTEGER StreamBytesTransferred,
+������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ DWORD dwStreamNumber, DWORD dwCallbackReason,
+������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ HANDLE hSourceFile,HANDLE hDestinationFile,
+������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ LPVOID lpData )
+{
+������ ������ int rval = 0;
+������ ������ ++test_MFWPChunks;
+������ ������ if(test_MFWPFailTest)
+������ ������ {
+������ ������ ������ ������ if (test_MFWPChunks > MFWP_ExpectedChunks/2)
+������ ������ ������ ������ {
+������ ������ ������ ������ ������ ������ rval=test_MFWPFailTest;
+������ ������ ������ ������ ������ ������ //trace("Exit %d at %d\n",rval,test_MFWPChunks);
+������ ������ ������ ������ }
+������ ������ }
+������ ������ //trace("Chunk %d %d\n",test_MFWPChunks,TotalBytesTransferred.QuadPart);
+������ ������ if(TotalBytesTransferred.QuadPart == TotalFileSize.QuadPart ) {
+������ ������ ������ ������ //trace("Chunks %d == %d\n",test_MFWPChunks,MFWP_ExpectedChunks);
+������ ������ ������ ������ ok(MFWP_ExpectedChunks == test_MFWPChunks,"Invalid move? %d chunks",test_MFWPChunks);
+������ ������ }
+������ ������ return rval;
+}
+
+static void test_MoveFileWithProgressW(void)
+{
+������ ������ char temp_path[MAX_PATH],tmpl[MAX_PATH];
+������ ������ char source[MAX_PATH], dest[MAX_PATH];
+������ ������ WCHAR wsrc[MAX_PATH],wdst[MAX_PATH];
+������ ������ static const char prefix[] = {'p','f','x',0};
+������ ������ char temp[2] = { 0, 0 };
+������ ������ char buffer[1024];
+������ ������ HANDLE handle;
+������ ������ DWORD ret;
+
+������ ������ trace("Running MoveFileWithProgressW() tests...");
+������ ������ ret = GetTempPathA(MAX_PATH, temp_path);
+������ ������ ok(ret != 0, "GetTempPathA error %d\n", GetLastError());
+������ ������ ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
+
+������ ������ ret = GetTempFileNameA(temp_path, prefix, 0, tmpl);
+������ ������ ok(ret != 0, "GetTempFileNameW error %d\n", GetLastError());
+������ ������ MultiByteToWideChar(CP_ACP,0,tmpl,-1,wdst,MAX_PATH);
+������ ������ ok(TRUE == DeleteFileW(wdst), "Failed to remove file %s\n",dest);
+
+������ ������ // create dummy data
+������ ������ snprintf(source,MAX_PATH,"%s.0",tmpl);
+������ ������ handle=CreateFileA(source, GENERIC_WRITE, 0, NULL, CREATE_NEW,
+������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������ ������FILE_ATTRIBUTE_NORMAL, 0);
+������ ������ ok(handle != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+������ ������ for(int megs=0; megs<MFWP_MB; ++megs)
+������ ������ {
+������ ������ ������ ������ for(int kilos=0; kilos<MFWP_Kilo; ++kilos)
+������ ������ ������ ������ {
+������ ������ ������ ������ ������ ������ ok(TRUE == WriteFile(handle, buffer, sizeof(buffer), NULL, NULL),
+������ ������ ������ ������ ������ ������ ������ ������ ������ ������ "Write file error %d\n", GetLastError());
+������ ������ ������ ������ }
+������ ������ }
+������ ������ ok(CloseHandle(handle) == TRUE, "Cannot close file %d\n",GetLastError());
+������ ������ // move the file a few times
+������ ������ for(int i=0;i<10;)
+������ ������ {
+������ ������ ������ ������ *temp='0'+i++;
+������ ������ ������ ������ snprintf(source,MAX_PATH,"%s.%s",tmpl,temp);
+������ ������ ������ ������ *temp='0'+i%10;
+������ ������ ������ ������ snprintf(dest,MAX_PATH,"%s.%s",tmpl,temp);
+������ ������ ������ ������ //trace("%s -> %s\n",source,dest);
+������ ������ ������ ������ MultiByteToWideChar(CP_ACP,0,source,-1,wsrc,MAX_PATH);
+������ ������ ������ ������ MultiByteToWideChar(CP_ACP,0,dest,-1,wdst,MAX_PATH);
+������ ������ ������ ������ test_MFWPChunks=0;
+������ ������ ������ ������ ok(TRUE == MoveFileWithProgressW(wsrc,wdst,test_MoveFileWithProgressWCB,
+������ ������ ������ ������ ������ ������ ������ ������ ������ ������ 0,MOVEFILE_WRITE_THROUGH),
+������ ������ ������ ������ ������ ������ ������ ������ "Failed to move file %s to %s\n",source,dest);
+������ ������ }
+������ ������ // fail to move the file
+������ ������ // stop will leave the 1/2 copied file in the directory
+������ ������ test_MFWPFailTest=PROGRESS_STOP;
+������ ������ test_MFWPChunks=0;
+������ ������ ok(FALSE == MoveFileWithProgressW(wdst,wsrc,test_MoveFileWithProgressWCB,
+������ ������ ������ ������ ������ ������ ������ ������ ������ ������ 0,MOVEFILE_WRITE_THROUGH),
+������ ������ ������ ������ ������ ������ ������ ������ "Moved file %s to %s????\n",source,dest);
+������ ������ ok(TRUE == DeleteFileW(wsrc), "File should exist %s\n",source);
+
+������ ������ // fail to move the file
+������ ������ // Cancel will delete the requested file
+������ ������ test_MFWPFailTest=PROGRESS_CANCEL;
+������ ������ test_MFWPChunks=0;
+������ ������ ok(FALSE == MoveFileWithProgressW(wdst,wsrc,test_MoveFileWithProgressWCB,
+������ ������ ������ ������ ������ ������ ������ ������ ������ ������ 0,MOVEFILE_WRITE_THROUGH),
+������ ������ ������ ������ ������ ������ ������ ������ "Moved file %s to %s????\n",source,dest);
+������ ������ ok(FALSE == DeleteFileW(wsrc), "Copy failed to clean up file %s\n",source);
+������ ������ // clean up
+������ ������ ok(TRUE == DeleteFileW(wdst), "Failed to remove file %s\n",dest);
+
+}
+
+
������START_TEST(file)
������{
������ ������ ������InitFunctionPointers();
@@ -4989,6 +5095,7 @@ START_TEST(file)
������ ������ ������test_DeleteFileW();
������ ������ ������test_MoveFileA();
������ ������ ������test_MoveFileW();
+������ ������ test_MoveFileWithProgressW();
������ ������ ������test_FindFirstFileA();
������ ������ ������test_FindNextFileA();
������ ������ ������test_FindFirstFile_wildcards();
--������
2.14.1