From 84445fb85a4a22588af798195fcefd7db31b17fd Mon Sep 17 00:00:00 2001 From: root Date: Fri, 21 Sep 2012 23:24:43 +0000 Subject: Fixed LockWindowUpdate --- dlls/user32/painting.c | 43 +++++++++-------- dlls/user32/tests/Makefile.in | 1 + dlls/user32/tests/painting.c | 103 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+), 19 deletions(-) create mode 100644 dlls/user32/tests/painting.c diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c index 1a6de87..c70298e 100644 --- a/dlls/user32/painting.c +++ b/dlls/user32/painting.c @@ -1154,32 +1154,37 @@ HWND WINAPI WindowFromDC( HDC hdc ) */ BOOL WINAPI LockWindowUpdate( HWND hwnd ) { - static HWND lockedWnd; + static HWND lockedWnd; - FIXME("(%p), partial stub!\n",hwnd); - - USER_Lock(); - if (lockedWnd) + USER_Lock(); + if (lockedWnd) { - if (!hwnd) - { - /* Unlock lockedWnd */ - /* FIXME: Do something */ - } - else - { - /* Attempted to lock a second window */ - /* Return FALSE and do nothing */ - USER_Unlock(); - return FALSE; + if (hwnd) + { + /* Attempted to lock a second window */ + /* Return FALSE and do nothing */ + USER_Unlock(); + return FALSE; } } - lockedWnd = hwnd; - USER_Unlock(); - return TRUE; + else /* Not locked */ + { + if (!hwnd) + { + /* Attempted to unlock while already unlocked */ + /* Return FALSE and do nothing */ + USER_Unlock(); + return FALSE; + } + + } + lockedWnd = hwnd; + USER_Unlock(); + return TRUE; } + /*********************************************************************** * RedrawWindow (USER32.@) */ diff --git a/dlls/user32/tests/Makefile.in b/dlls/user32/tests/Makefile.in index eb5789a..24ff612 100644 --- a/dlls/user32/tests/Makefile.in +++ b/dlls/user32/tests/Makefile.in @@ -17,6 +17,7 @@ C_SRCS = \ menu.c \ monitor.c \ msg.c \ + painting.c \ resource.c \ scroll.c \ static.c \ diff --git a/dlls/user32/tests/painting.c b/dlls/user32/tests/painting.c new file mode 100644 index 0000000..8b08ea2 --- /dev/null +++ b/dlls/user32/tests/painting.c @@ -0,0 +1,103 @@ +#include +#include +#include +#include + +/* Maybe auxiliary functions and definitions here */ +static HINSTANCE hinst; +static HWND create_editcontrol (DWORD style, DWORD exstyle) +{ + HWND handle; + + handle = CreateWindowEx(exstyle, + "EDIT", + "Test Text", + style, + 10, 10, 300, 300, + NULL, NULL, hinst, NULL); + ok (handle != NULL, "CreateWindow EDIT Control failed\n"); + assert (handle); + if (winetest_interactive) + ShowWindow (handle, SW_SHOW); + return handle; +} + +/* lock valid window, nothing locked */ +static void test_lockwindowupdate_1(void) +{ + HWND handle; + BOOL ret; + + handle = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + assert (handle); + + /* normal, successful window lock */ + ret = LockWindowUpdate(handle); + ok(0 != ret, "LockWindowUpdate: scenario 1 failed to lock\n"); + + /* locking NULL when a window is locked will unlock it */ + ret = LockWindowUpdate(NULL); + ok(0 != ret, "LockWindowUpdate: scenario 1 failed \n"); +} + +/* lock valid window, already locked */ +static void test_lockwindowupdate_2(void) +{ + HWND handle; + HWND handle_2; + BOOL ret; + + handle = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + assert (handle); + handle_2 = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + assert (handle_2); + + /* normal, successful window lock */ + ret = LockWindowUpdate(handle); + ok(0 != ret, "LockWindowUpdate: scenario 2 failed to lock\n"); + + /* attempt to lock a second window should fail */ + ret = LockWindowUpdate(handle_2); + ok(0 == ret, "LockWindowUpdate: scenario 2 failed on second lock\n"); + + /* lock NULL to clear the lock */ + ret = LockWindowUpdate(NULL); + ok(0 != ret, "LockWindowUpdate: scenario 2 failed to clear lock\n"); +} + + +/* lock NULL window, nothing locked */ +static void test_lockwindowupdate_3(void) +{ + BOOL ret; + /* locking NULL when nothing is locked should be an error */ + ret = LockWindowUpdate(NULL); + ok(0 == ret, "LockWindowUpdate: scenario 3 failed, returned %d\n", ret); +} + +/* lock NULL window, already locked */ +static void test_lockwindowupdate_4(void) +{ + HWND handle; + BOOL ret; + + handle = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + assert (handle); + + /* normal, successful window lock */ + ret = LockWindowUpdate(handle); + ok(0 != ret, "LockWindowUpdate: scenario 4 failed to lock window\n"); + + /* locking NULL should unlock the window */ + ret = LockWindowUpdate(NULL); + ok(0 != ret, "LockWindowUpdate: scenario 4 failed to unlock window\n"); +} + +START_TEST(painting) +{ + trace("testing LockWindowUpdate\n"); + test_lockwindowupdate_1(); + test_lockwindowupdate_2(); + test_lockwindowupdate_3(); + test_lockwindowupdate_4(); +} -- 1.7.9.5