1 /* 2 * PROJECT: ReactOS API tests 3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory 4 * PURPOSE: Test for SetScrollRange 5 * PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org> 6 */ 7 8 #include "precomp.h" 9 10 START_TEST(SetScrollRange) 11 { 12 struct 13 { 14 INT nMin; 15 INT nMax; 16 BOOL result; 17 } tests[] = 18 { 19 { 0, 0, TRUE }, 20 { 0, INT_MAX, TRUE }, 21 { -1, INT_MAX, FALSE }, 22 { INT_MIN, INT_MAX, FALSE }, 23 { INT_MIN, 0, FALSE }, 24 { INT_MIN, -1, TRUE }, 25 }; 26 unsigned i; 27 HWND hScroll; 28 BOOL success; 29 DWORD error; 30 INT newMin, newMax; 31 32 hScroll = CreateWindowExW(0, L"SCROLLBAR", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); 33 ok(hScroll != NULL, "CreateWindowEx failed with %lu\n", GetLastError()); 34 if (!hScroll) 35 { 36 skip("No scroll bar\n"); 37 return; 38 } 39 40 for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) 41 { 42 (void)SetScrollRange(hScroll, SB_CTL, 123, 456, FALSE); 43 SetLastError(0xdeaff00d); 44 success = SetScrollRange(hScroll, SB_CTL, tests[i].nMin, tests[i].nMax, FALSE); 45 error = GetLastError(); 46 (void)GetScrollRange(hScroll, SB_CTL, &newMin, &newMax); 47 if (tests[i].result) 48 { 49 ok(success == TRUE, "SetScrollRange(%d, %d) failed with %d %lu\n", tests[i].nMin, tests[i].nMax, success, error); 50 ok(newMin == tests[i].nMin, "nMin was changed to %d\n", tests[i].nMin); 51 ok(newMax == tests[i].nMax, "nMax was changed to %d\n", tests[i].nMax); 52 } 53 else 54 { 55 ok(success == FALSE, "SetScrollRange(%d, %d) succeeded with %d\n", tests[i].nMin, tests[i].nMax, success); 56 ok(error == ERROR_INVALID_SCROLLBAR_RANGE, "Error %lu\n", error); 57 ok(newMin == 123, "nMin was changed to %d\n", newMin); 58 ok(newMax == 456, "nMax was changed to %d\n", newMax); 59 } 60 } 61 62 DestroyWindow(hScroll); 63 } 64