Nikolay Sivov : comctl32/ipaddress: Fix IPM_CLEARADDRESS return value.

Alexandre Julliard julliard at winehq.org
Fri Oct 9 16:00:44 CDT 2020


Module: wine
Branch: master
Commit: 573b3eb432fb56dd949da48275f3d0162c8424eb
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=573b3eb432fb56dd949da48275f3d0162c8424eb

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri Oct  9 13:35:17 2020 +0300

comctl32/ipaddress: Fix IPM_CLEARADDRESS return value.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comctl32/ipaddress.c       |  7 ++++---
 dlls/comctl32/tests/ipaddress.c | 43 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/dlls/comctl32/ipaddress.c b/dlls/comctl32/ipaddress.c
index 32816561e3..82d47d4e57 100644
--- a/dlls/comctl32/ipaddress.c
+++ b/dlls/comctl32/ipaddress.c
@@ -354,7 +354,7 @@ static BOOL IPADDRESS_SetRange (IPADDRESS_INFO *infoPtr, int index, WORD range)
 }
 
 
-static void IPADDRESS_ClearAddress (const IPADDRESS_INFO *infoPtr)
+static LRESULT IPADDRESS_ClearAddress (const IPADDRESS_INFO *infoPtr)
 {
     int i;
 
@@ -362,6 +362,8 @@ static void IPADDRESS_ClearAddress (const IPADDRESS_INFO *infoPtr)
 
     for (i = 0; i < 4; i++)
         SetWindowTextW (infoPtr->Part[i].EditHwnd, L"");
+
+    return 1;
 }
 
 
@@ -614,8 +616,7 @@ IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
             return 0;
 
         case IPM_CLEARADDRESS:
-            IPADDRESS_ClearAddress (infoPtr);
-	    break;
+            return IPADDRESS_ClearAddress (infoPtr);
 
         case IPM_SETADDRESS:
             return IPADDRESS_SetAddress (infoPtr, (DWORD)lParam);
diff --git a/dlls/comctl32/tests/ipaddress.c b/dlls/comctl32/tests/ipaddress.c
index c87d0f5664..2df25a5a65 100644
--- a/dlls/comctl32/tests/ipaddress.c
+++ b/dlls/comctl32/tests/ipaddress.c
@@ -144,6 +144,47 @@ static void test_WM_SETFOCUS(void)
     DestroyWindow(hwnd);
 }
 
+static void test_IPM_CLEARADDRESS(void)
+{
+    struct child_enum child_enum = {{ 0 }};
+    char buff[16];
+    int i, ret;
+    HWND hwnd;
+
+    hwnd = create_ipaddress_control();
+    ok(!!hwnd, "Failed to create control.\n");
+
+    ret = SendMessageA(hwnd, IPM_SETADDRESS, 0, MAKEIPADDRESS(0, 1, 2, 3));
+    ok(ret == 1, "Unexpected return value %d.\n", ret);
+
+    EnumChildWindows(hwnd, test_child_enum_proc, (LPARAM)&child_enum);
+    ok(child_enum.count == 4, "Unexpected child count %u.\n", child_enum.count);
+
+    ret = SendMessageA(hwnd, IPM_SETADDRESS, 0, MAKEIPADDRESS(1, 2, 3, 4));
+    ok(ret == 1, "Unexpected return value %d.\n", ret);
+
+    ret = GetWindowTextA(hwnd, buff, ARRAY_SIZE(buff));
+    ok(ret == 7, "Unexpected return value %d.\n", ret);
+    ok(!strcmp(buff, "1.2.3.4"), "Unexpected address %s.\n", buff);
+
+    ret = SendMessageA(hwnd, IPM_CLEARADDRESS, 0, 0);
+    ok(ret, "Unexpected return value %d.\n", ret);
+
+    ret = GetWindowTextA(hwnd, buff, ARRAY_SIZE(buff));
+    ok(ret == 7, "Unexpected return value %d.\n", ret);
+    ok(!strcmp(buff, "0.0.0.0"), "Unexpected address %s.\n", buff);
+
+    for (i = 0; i < 4; ++i)
+    {
+        buff[0] = 1;
+        ret = GetWindowTextA(child_enum.fields[i], buff, ARRAY_SIZE(buff));
+        ok(ret == 0, "Unexpected return value %d.\n", ret);
+        ok(!*buff, "Unexpected field text %s.\n", buff);
+    }
+
+    DestroyWindow(hwnd);
+}
+
 START_TEST(ipaddress)
 {
     ULONG_PTR cookie;
@@ -152,6 +193,7 @@ START_TEST(ipaddress)
     test_get_set_text();
     test_IPM_SETFOCUS();
     test_WM_SETFOCUS();
+    test_IPM_CLEARADDRESS();
 
     if (!load_v6_module(&cookie, &ctxt))
         return;
@@ -159,6 +201,7 @@ START_TEST(ipaddress)
     test_get_set_text();
     test_IPM_SETFOCUS();
     test_WM_SETFOCUS();
+    test_IPM_CLEARADDRESS();
 
     unload_v6_module(cookie, ctxt);
 }




More information about the wine-cvs mailing list