comctl32/tests: Use SetRect() instead of open coding it.

Michael Stefaniuc mstefani at redhat.de
Fri Apr 8 06:38:03 CDT 2016


Signed-off-by: Michael Stefaniuc <mstefani at redhat.de>
---
 dlls/comctl32/tests/animate.c  |   5 +-
 dlls/comctl32/tests/listview.c | 132 ++++++++++++-----------------------------
 dlls/comctl32/tests/monthcal.c |   2 +-
 dlls/comctl32/tests/progress.c |   7 +--
 4 files changed, 42 insertions(+), 104 deletions(-)

diff --git a/dlls/comctl32/tests/animate.c b/dlls/comctl32/tests/animate.c
index b4218db..c64dbfa 100644
--- a/dlls/comctl32/tests/animate.c
+++ b/dlls/comctl32/tests/animate.c
@@ -88,10 +88,7 @@ static void create_animate(DWORD parent_style, DWORD animate_style)
     wc.lpfnWndProc = animate_test_wnd_proc;
     RegisterClassA(&wc);
 
-    rect.left = 0;
-    rect.top = 0;
-    rect.right = 200;
-    rect.bottom = 200;
+    SetRect(&rect, 0, 0, 200, 200);
     ret = AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
     ok(ret, "got %d\n", ret);
 
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 400c51a..10e7d0e 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -1707,9 +1707,7 @@ static void test_create(void)
     ok(!IsWindow(hHeader), "Header shouldn't be created\n");
     ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
 
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 1;
-    rect.right = rect.bottom = -10;
+    SetRect(&rect, LVIR_BOUNDS, 1, -10, -10);
     r = SendMessageA(hList, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
     /* right value contains garbage, probably because header columns are not set up */
     expect(0, rect.bottom);
@@ -2610,15 +2608,11 @@ static void test_subitem_rect(void)
     r = SendMessageA(hwnd, LVM_INSERTCOLUMNA, 2, (LPARAM)&col);
     expect(2, r);
     /* item = -1 means header, subitem index is 1 based */
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 0;
-    rect.right = rect.bottom = 0;
+    SetRect(&rect, LVIR_BOUNDS, 0, 0, 0);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
     expect(0, r);
 
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 1;
-    rect.right = rect.bottom = 0;
+    SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
     expect(1, r);
 
@@ -2626,9 +2620,7 @@ static void test_subitem_rect(void)
     expect(250, rect.right);
     expect(3, rect.top);
 
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 2;
-    rect.right = rect.bottom = 0;
+    SetRect(&rect, LVIR_BOUNDS, 2, 0, 0);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
     expect(1, r);
 
@@ -2639,26 +2631,20 @@ static void test_subitem_rect(void)
     /* item LVS_REPORT padding isn't applied to subitems */
     insert_item(hwnd, 0);
 
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 1;
-    rect.right = rect.bottom = 0;
+    SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
     expect(1, r);
     expect(100, rect.left);
     expect(250, rect.right);
 
-    rect.left = LVIR_ICON;
-    rect.top  = 1;
-    rect.right = rect.bottom = 0;
+    SetRect(&rect, LVIR_ICON, 1, 0, 0);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
     expect(1, r);
     /* no icon attached - zero width rectangle, with no left padding */
     expect(100, rect.left);
     expect(100, rect.right);
 
-    rect.left = LVIR_LABEL;
-    rect.top  = 1;
-    rect.right = rect.bottom = 0;
+    SetRect(&rect, LVIR_LABEL, 1, 0, 0);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
     expect(1, r);
     /* same as full LVIR_BOUNDS */
@@ -2667,9 +2653,7 @@ static void test_subitem_rect(void)
 
     SendMessageA(hwnd, LVM_SCROLL, 10, 0);
 
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 1;
-    rect.right = rect.bottom = 0;
+    SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
     expect(1, r);
     expect(90, rect.left);
@@ -2681,27 +2665,19 @@ static void test_subitem_rect(void)
     subclass_header(hwnd);
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
 
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 1;
-    rect.right = rect.bottom = 0;
+    SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
     expect(1, r);
 
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 1;
-    rect.right = rect.bottom = 0;
+    SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
     expect(1, r);
 
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 1;
-    rect.right = rect.bottom = 0;
+    SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, -10, (LPARAM)&rect);
     expect(1, r);
 
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 1;
-    rect.right = rect.bottom = 0;
+    SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 20, (LPARAM)&rect);
     expect(1, r);
 
@@ -2731,22 +2707,16 @@ static void test_subitem_rect(void)
     insert_item(hwnd, 1);
 
     /* wrong item is refused for main item */
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 0;
-    rect.right = rect.bottom = -1;
+    SetRect(&rect, LVIR_BOUNDS, 0, -1, -1);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 2, (LPARAM)&rect);
     expect(FALSE, r);
 
     /* for subitems rectangle is calculated even if there's no item added */
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 1;
-    rect.right = rect.bottom = -1;
+    SetRect(&rect, LVIR_BOUNDS, 1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 1, (LPARAM)&rect);
     expect(TRUE, r);
 
-    rect2.left = LVIR_BOUNDS;
-    rect2.top  = 1;
-    rect2.right = rect2.bottom = -1;
+    SetRect(&rect2, LVIR_BOUNDS, 1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 2, (LPARAM)&rect2);
     expect(TRUE, r);
     expect(rect.right, rect2.right);
@@ -2758,25 +2728,19 @@ static void test_subitem_rect(void)
     r = SendMessageA(hwnd, LVM_SETCOLUMNORDERARRAY, 3, (LPARAM)arr);
     expect(TRUE, r);
 
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 0;
-    rect.right = rect.bottom = -1;
+    SetRect(&rect, LVIR_BOUNDS, 0, -1, -1);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     expect(0, rect.left);
     expect(600, rect.right);
 
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 1;
-    rect.right = rect.bottom = -1;
+    SetRect(&rect, LVIR_BOUNDS, 1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     expect(0, rect.left);
     expect(200, rect.right);
 
-    rect2.left = LVIR_BOUNDS;
-    rect2.top  = 1;
-    rect2.right = rect2.bottom = -1;
+    SetRect(&rect2, LVIR_BOUNDS, 1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 1, (LPARAM)&rect2);
     expect(TRUE, r);
     expect(0, rect2.left);
@@ -2786,9 +2750,7 @@ static void test_subitem_rect(void)
     expect(rect.bottom, rect2.top);
     expect(rect.bottom * 2 - rect.top, rect2.bottom);
 
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 2;
-    rect.right = rect.bottom = -1;
+    SetRect(&rect, LVIR_BOUNDS, 2, -1, -1);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     expect(300, rect.left);
@@ -2799,9 +2761,7 @@ static void test_subitem_rect(void)
     /* try it for non LVS_REPORT style */
     hwnd = CreateWindowA("SysListView32", "Test", LVS_ICON, 0, 0, 100, 100, NULL, NULL,
                          GetModuleHandleA(NULL), 0);
-    rect.left = LVIR_BOUNDS;
-    rect.top  = 1;
-    rect.right = rect.bottom = -10;
+    SetRect(&rect, LVIR_BOUNDS, 1, -10, -10);
     r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
     expect(0, r);
     /* rect is unchanged */
@@ -3816,7 +3776,7 @@ static void test_getviewrect(void)
     r = SendMessageA(hwnd, LVM_SETCOLUMNWIDTH, 1, MAKELPARAM(120, 0));
     expect(TRUE, r);
 
-    rect.left = rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, -1, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* left is set to (2e31-1) - XP SP2 */
@@ -3827,7 +3787,7 @@ static void test_getviewrect(void)
     /* switch to LVS_ICON */
     SetWindowLongA(hwnd, GWL_STYLE, GetWindowLongA(hwnd, GWL_STYLE) & ~LVS_REPORT);
 
-    rect.left = rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, -1, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     expect(0, rect.left);
@@ -3938,8 +3898,7 @@ todo_wine
     r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
     expect(0, r);
 
-    rect.left = LVIR_BOUNDS;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_BOUNDS, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
 
@@ -3960,8 +3919,7 @@ todo_wine
     r = SendMessageA(hwnd, LVM_SETCOLUMNA, 1, (LPARAM)&col);
     expect(TRUE, r);
 
-    rect.left = LVIR_BOUNDS;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_BOUNDS, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
 
@@ -3969,15 +3927,13 @@ todo_wine
     expect(0, rect.left);
     expect(150, rect.right);
 
-    rect.left = LVIR_SELECTBOUNDS;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_SELECTBOUNDS, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* padding */
     expect(2, rect.left);
 
-    rect.left = LVIR_LABEL;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_LABEL, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* padding, column width */
@@ -3985,8 +3941,7 @@ todo_wine
     expect(50, rect.right);
 
     /* no icons attached */
-    rect.left = LVIR_ICON;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_ICON, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* padding */
@@ -4003,16 +3958,14 @@ todo_wine
     /* 1 indexed column width + padding */
     expect(102, pt.x);
     /* rect is at zero too */
-    rect.left = LVIR_BOUNDS;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_BOUNDS, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     expect(0, rect.left);
     /* just width sum */
     expect(150, rect.right);
 
-    rect.left = LVIR_SELECTBOUNDS;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_SELECTBOUNDS, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* column width + padding */
@@ -4047,16 +4000,14 @@ todo_wine
     expect(TRUE, r);
 
     /* icon bounds */
-    rect.left = LVIR_ICON;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_ICON, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* padding + stateicon width */
     expect(18, rect.left);
     expect(18, rect.right);
     /* label bounds */
-    rect.left = LVIR_LABEL;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_LABEL, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* padding + stateicon width -> column width */
@@ -4079,16 +4030,14 @@ todo_wine
     expect(TRUE, r);
 
     /* icon bounds */
-    rect.left = LVIR_ICON;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_ICON, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* padding, icon width */
     expect(2, rect.left);
     expect(18, rect.right);
     /* label bounds */
-    rect.left = LVIR_LABEL;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_LABEL, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* padding + icon width -> column width */
@@ -4096,8 +4045,7 @@ todo_wine
     expect(50, rect.right);
 
     /* select bounds */
-    rect.left = LVIR_SELECTBOUNDS;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_SELECTBOUNDS, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* padding, column width */
@@ -4113,8 +4061,7 @@ todo_wine
     expect(TRUE, r);
 
     /* bounds */
-    rect.left = LVIR_BOUNDS;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_BOUNDS, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* padding + 1 icon width, column width */
@@ -4122,8 +4069,7 @@ todo_wine
     expect(150, rect.right);
 
     /* select bounds */
-    rect.left = LVIR_SELECTBOUNDS;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_SELECTBOUNDS, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* padding + 1 icon width, column width */
@@ -4131,8 +4077,7 @@ todo_wine
     expect(50, rect.right);
 
     /* label bounds */
-    rect.left = LVIR_LABEL;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_LABEL, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* padding + 2 icon widths, column width */
@@ -4140,8 +4085,7 @@ todo_wine
     expect(50, rect.right);
 
     /* icon bounds */
-    rect.left = LVIR_ICON;
-    rect.right = rect.top = rect.bottom = -1;
+    SetRect(&rect, LVIR_ICON, -1, -1, -1);
     r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
     expect(TRUE, r);
     /* padding + 1 icon width indentation, icon width */
diff --git a/dlls/comctl32/tests/monthcal.c b/dlls/comctl32/tests/monthcal.c
index 24dcdfc..30da089 100644
--- a/dlls/comctl32/tests/monthcal.c
+++ b/dlls/comctl32/tests/monthcal.c
@@ -1895,7 +1895,7 @@ static void test_MCM_SIZERECTTOMIN(void)
     ret = SendMessageA(hwnd, MCM_SIZERECTTOMIN, 0, 0);
     ok(ret == 0, "got %d\n", ret);
 
-    r.left = r.right = r.top = r.bottom = 0;
+    SetRectEmpty(&r);
     ret = SendMessageA(hwnd, MCM_SIZERECTTOMIN, 0, (LPARAM)&r);
     if (ret == 0)
     {
diff --git a/dlls/comctl32/tests/progress.c b/dlls/comctl32/tests/progress.c
index 19e84cd..f7ae328 100644
--- a/dlls/comctl32/tests/progress.c
+++ b/dlls/comctl32/tests/progress.c
@@ -123,11 +123,8 @@ static void init(void)
     wc.lpszClassName = progressTestClass;
     wc.lpfnWndProc = progress_test_wnd_proc;
     RegisterClassA(&wc);
-    
-    rect.left = 0;
-    rect.top = 0;
-    rect.right = 400;
-    rect.bottom = 20;
+
+    SetRect(&rect, 0, 0, 400, 20);
     ret = AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
     ok(ret, "got %d\n", ret);
     
-- 
2.4.11



More information about the wine-patches mailing list