<div dir="ltr"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="text-align:start;text-indent:0px;text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px;text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Signed-off-by: Tom Watson <<a href="mailto:coder@tommywatson.com" style="color:rgb(17,85,204)" target="_blank">coder@tommywatson.com</a>></span></span></div><div style="text-align:start;text-indent:0px;text-decoration-style:initial;text-decoration-color:initial">---</div><div> dlls/kernel32/tests/file.c | 107 +++++++++++++++++++++++++++++++++++++++++++++</div><div> 1 file changed, 107 insertions(+)</div><div><br></div><div>diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c</div><div>index 410c3f0591..43b9143322 100644</div><div>--- a/dlls/kernel32/tests/file.c</div><div>+++ b/dlls/kernel32/tests/file.c</div><div>@@ -4964,6 +4964,112 @@ static void test_GetFileAttributesExW(void)</div><div>     ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected error ERROR_FILE_NOT_FOUND, got %u\n", GetLastError());</div><div> }</div><div> </div><div>+// constant defined in path.c, CopyFileExW()</div><div>+#define MFWP_CopyFileExW_BufferLength   65536</div><div>+#define MFWP_MB                         128     // 128 MB file</div><div>+#define MFWP_Kilo                       1024</div><div>+#define MFWP_ExpectedChunks             ((MFWP_MB*MFWP_Kilo*MFWP_Kilo)/MFWP_CopyFileExW_BufferLength)</div><div>+static int test_MFWPChunks = 0;</div><div>+static int test_MFWPFailTest = 0;</div><div>+DWORD CALLBACK test_MoveFileWithProgressWCB(LARGE_INTEGER TotalFileSize,</div><div>+                              LARGE_INTEGER TotalBytesTransferred,</div><div>+                              LARGE_INTEGER StreamSize,</div><div>+                              LARGE_INTEGER StreamBytesTransferred,</div><div>+                              DWORD dwStreamNumber, DWORD dwCallbackReason,</div><div>+                              HANDLE hSourceFile,HANDLE hDestinationFile,</div><div>+                              LPVOID lpData )</div><div>+{</div><div>+    int rval = 0;</div><div>+    ++test_MFWPChunks;</div><div>+    if(test_MFWPFailTest)</div><div>+    {</div><div>+        if (test_MFWPChunks > MFWP_ExpectedChunks/2)</div><div>+        {</div><div>+            rval=test_MFWPFailTest;</div><div>+            //trace("Exit %d at %d\n",rval,test_MFWPChunks);</div><div>+        }</div><div>+    }</div><div>+    //trace("Chunk %d %d\n",test_MFWPChunks,TotalBytesTransferred.QuadPart);</div><div>+    if(TotalBytesTransferred.QuadPart == TotalFileSize.QuadPart ) {</div><div>+        //trace("Chunks %d == %d\n",test_MFWPChunks,MFWP_ExpectedChunks);</div><div>+        ok(MFWP_ExpectedChunks == test_MFWPChunks,"Invalid move? %d chunks",test_MFWPChunks);</div><div>+    }</div><div>+    return rval;</div><div>+}</div><div>+</div><div>+static void test_MoveFileWithProgressW(void)</div><div>+{</div><div>+    char temp_path[MAX_PATH],tmpl[MAX_PATH];</div><div>+    char source[MAX_PATH], dest[MAX_PATH];</div><div>+    WCHAR wsrc[MAX_PATH],wdst[MAX_PATH];</div><div>+    static const char prefix[] = {'p','f','x',0};</div><div>+    char temp[2] = { 0, 0 };</div><div>+    char buffer[1024];</div><div>+    HANDLE handle;</div><div>+    DWORD ret;</div><div>+</div><div>+    trace("Running MoveFileWithProgressW() tests...");</div><div>+    ret = GetTempPathA(MAX_PATH, temp_path);</div><div>+    ok(ret != 0, "GetTempPathA error %d\n", GetLastError());</div><div>+    ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");</div><div>+</div><div>+    ret = GetTempFileNameA(temp_path, prefix, 0, tmpl);</div><div>+    ok(ret != 0, "GetTempFileNameW error %d\n", GetLastError());</div><div>+    MultiByteToWideChar(CP_ACP,0,tmpl,-1,wdst,MAX_PATH);</div><div>+    ok(TRUE == DeleteFileW(wdst), "Failed to remove file %s\n",dest);</div><div>+</div><div>+    // create dummy data</div><div>+    snprintf(source,MAX_PATH,"%s.0",tmpl);</div><div>+    handle=CreateFileA(source, GENERIC_WRITE, 0, NULL, CREATE_NEW,</div><div>+                       FILE_ATTRIBUTE_NORMAL, 0);</div><div>+    ok(handle != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());</div><div>+    for(int megs=0; megs<MFWP_MB; ++megs)</div><div>+    {</div><div>+        for(int kilos=0; kilos<MFWP_Kilo; ++kilos)</div><div>+        {</div><div>+            ok(TRUE == WriteFile(handle, buffer, sizeof(buffer), NULL, NULL),</div><div>+                    "Write file error %d\n", GetLastError());</div><div>+        }</div><div>+    }</div><div>+    ok(CloseHandle(handle) == TRUE, "Cannot close file %d\n",GetLastError());</div><div>+    // move the file a few times</div><div>+    for(int i=0;i<10;)</div><div>+    {</div><div>+        *temp='0'+i++;</div><div>+        snprintf(source,MAX_PATH,"%s.%s",tmpl,temp);</div><div>+        *temp='0'+i%10;</div><div>+        snprintf(dest,MAX_PATH,"%s.%s",tmpl,temp);</div><div>+        //trace("%s -> %s\n",source,dest);</div><div>+        MultiByteToWideChar(CP_ACP,0,source,-1,wsrc,MAX_PATH);</div><div>+        MultiByteToWideChar(CP_ACP,0,dest,-1,wdst,MAX_PATH);</div><div>+        test_MFWPChunks=0;</div><div>+        ok(TRUE == MoveFileWithProgressW(wsrc,wdst,test_MoveFileWithProgressWCB,</div><div>+                    0,MOVEFILE_WRITE_THROUGH),</div><div>+                "Failed to move file %s to %s\n",source,dest);</div><div>+    }</div><div>+    // fail to move the file</div><div>+    // stop will leave the 1/2 copied file in the directory</div><div>+    test_MFWPFailTest=PROGRESS_STOP;</div><div>+    test_MFWPChunks=0;</div><div>+    ok(FALSE == MoveFileWithProgressW(wdst,wsrc,test_MoveFileWithProgressWCB,</div><div>+                    0,MOVEFILE_WRITE_THROUGH),</div><div>+                "Moved file %s to %s????\n",source,dest);</div><div>+    ok(TRUE == DeleteFileW(wsrc), "File should exist %s\n",source);</div><div>+</div><div>+    // fail to move the file</div><div>+    // Cancel will delete the requested file</div><div>+    test_MFWPFailTest=PROGRESS_CANCEL;</div><div>+    test_MFWPChunks=0;</div><div>+    ok(FALSE == MoveFileWithProgressW(wdst,wsrc,test_MoveFileWithProgressWCB,</div><div>+                    0,MOVEFILE_WRITE_THROUGH),</div><div>+                "Moved file %s to %s????\n",source,dest);</div><div>+    ok(FALSE == DeleteFileW(wsrc), "Copy failed to clean up file %s\n",source);</div><div>+    // clean up</div><div>+    ok(TRUE == DeleteFileW(wdst), "Failed to remove file %s\n",dest);</div><div>+</div><div>+}</div><div>+</div><div>+</div><div> START_TEST(file)</div><div> {</div><div>     InitFunctionPointers();</div><div>@@ -4989,6 +5095,7 @@ START_TEST(file)</div><div>     test_DeleteFileW();</div><div>     test_MoveFileA();</div><div>     test_MoveFileW();</div><div>+    test_MoveFileWithProgressW();</div><div>     test_FindFirstFileA();</div><div>     test_FindNextFileA();</div><div>     test_FindFirstFile_wildcards();</div><div>-- </div><div>2.14.1</div><div><br></div><div><br></div></div>