Andrew Eikum : comdlg32/tests: Untie ok_testcases from test_ok().

Alexandre Julliard julliard at winehq.org
Fri Jul 23 10:05:48 CDT 2010


Module: wine
Branch: master
Commit: 93f9b4e1442bfa14ab32e64eb9286dc717d79610
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=93f9b4e1442bfa14ab32e64eb9286dc717d79610

Author: Andrew Eikum <aeikum at codeweavers.com>
Date:   Thu Jul 22 14:18:37 2010 -0500

comdlg32/tests: Untie ok_testcases from test_ok().

---

 dlls/comdlg32/tests/filedlg.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/dlls/comdlg32/tests/filedlg.c b/dlls/comdlg32/tests/filedlg.c
index 71f7d2a..5333c7f 100644
--- a/dlls/comdlg32/tests/filedlg.c
+++ b/dlls/comdlg32/tests/filedlg.c
@@ -562,14 +562,16 @@ static void test_resize(void)
 
 /* test cases for control message IDOK */
 /* Show case for bug #19079 */
-static struct {
+typedef struct {
     int  retval;        /* return code of the message handler */
     BOOL setmsgresult;  /* set the result in the DWLP_MSGRESULT */
     BOOL usemsgokstr;   /* use the FILEOKSTRING message instead of WM_NOTIFY:CDN_FILEOK */
     BOOL do_subclass;   /* subclass the dialog hook procedure */
     BOOL expclose;      /* is the dialog expected to close ? */
     BOOL actclose;      /* has the dialog actually closed ? */
-} ok_testcases[] = {
+} ok_wndproc_testcase;
+
+static ok_wndproc_testcase ok_testcases[] = {
     { 0,        FALSE,  FALSE,  FALSE,  TRUE},
     { 0,         TRUE,  FALSE,  FALSE,  TRUE},
     { 0,        FALSE,  FALSE,   TRUE,  TRUE},
@@ -590,12 +592,12 @@ static struct {
 static LONG_PTR WINAPI test_ok_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
     HWND parent = GetParent( dlg);
-    static int index;
+    static ok_wndproc_testcase *testcase = NULL;
     static UINT msgFILEOKSTRING;
     if (msg == WM_INITDIALOG)
     {
-        index = ((OPENFILENAME*)lParam)->lCustData;
-        ok_testcases[index].actclose = TRUE;
+        testcase = (ok_wndproc_testcase*)((OPENFILENAME*)lParam)->lCustData;
+        testcase->actclose = TRUE;
         msgFILEOKSTRING = RegisterWindowMessageA( FILEOKSTRING);
     }
     if( msg == WM_NOTIFY) {
@@ -604,28 +606,28 @@ static LONG_PTR WINAPI test_ok_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM
             PostMessage( parent, WM_COMMAND, IDOK, 0);
             return FALSE;
         } else if(((LPNMHDR)lParam)->code == CDN_FILEOK) {
-            if( ok_testcases[index].usemsgokstr)
+            if( testcase->usemsgokstr)
                 return FALSE;
-            if( ok_testcases[index].setmsgresult)
-                SetWindowLongPtrA( dlg, DWLP_MSGRESULT, ok_testcases[index].retval);
-            return ok_testcases[index].retval;
+            if( testcase->setmsgresult)
+                SetWindowLongPtrA( dlg, DWLP_MSGRESULT, testcase->retval);
+            return testcase->retval;
         }
     }
     if( msg == msgFILEOKSTRING) {
-        if( !ok_testcases[index].usemsgokstr)
+        if( !testcase->usemsgokstr)
             return FALSE;
-        if( ok_testcases[index].setmsgresult)
-            SetWindowLongPtrA( dlg, DWLP_MSGRESULT, ok_testcases[index].retval);
-        return ok_testcases[index].retval;
+        if( testcase->setmsgresult)
+            SetWindowLongPtrA( dlg, DWLP_MSGRESULT, testcase->retval);
+        return testcase->retval;
     }
     if( msg == WM_TIMER) {
         /* the dialog did not close automatically */
-        ok_testcases[index].actclose = FALSE;
+        testcase->actclose = FALSE;
         KillTimer( dlg, 0);
         PostMessage( parent, WM_COMMAND, IDCANCEL, 0);
         return FALSE;
     }
-    if( ok_testcases[index].do_subclass)
+    if( testcase && testcase->do_subclass)
         return DefWindowProc( dlg, msg, wParam, lParam);
     return FALSE;
 }
@@ -658,7 +660,7 @@ static void test_ok(void)
     ofn.Flags =  OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE ;
     for( i = 0; ok_testcases[i].retval != -1; i++) {
         strcpy( filename, tmpfilename);
-        ofn.lCustData = i;
+        ofn.lCustData = (LPARAM)(ok_testcases + i);
         ofn.lpfnHook = ok_testcases[i].do_subclass
             ? (LPOFNHOOKPROC) ok_template_hook
             : (LPOFNHOOKPROC) test_ok_wndproc;




More information about the wine-cvs mailing list