[USER32_APITEST]
[reactos.git] / rostests / apitests / user32 / SetScrollRange.c
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 <apitest.h>
9
10 #include <wingdi.h>
11 #include <winuser.h>
12
13 START_TEST(SetScrollRange)
14 {
15 struct
16 {
17 INT nMin;
18 INT nMax;
19 BOOL result;
20 } tests[] =
21 {
22 { 0, 0, TRUE },
23 { 0, INT_MAX, TRUE },
24 { -1, INT_MAX, FALSE },
25 { INT_MIN, INT_MAX, FALSE },
26 { INT_MIN, 0, FALSE },
27 { INT_MIN, -1, TRUE },
28 };
29 unsigned i;
30 HWND hScroll;
31 BOOL success;
32 DWORD error;
33 INT newMin, newMax;
34
35 hScroll = CreateWindowExW(0, L"SCROLLBAR", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
36 ok(hScroll != NULL, "CreateWindowEx failed with %lu\n", GetLastError());
37 if (!hScroll)
38 {
39 skip("No scroll bar\n");
40 return;
41 }
42
43 for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
44 {
45 (void)SetScrollRange(hScroll, SB_CTL, 123, 456, FALSE);
46 SetLastError(0xdeaff00d);
47 success = SetScrollRange(hScroll, SB_CTL, tests[i].nMin, tests[i].nMax, FALSE);
48 error = GetLastError();
49 (void)GetScrollRange(hScroll, SB_CTL, &newMin, &newMax);
50 if (tests[i].result)
51 {
52 ok(success == TRUE, "SetScrollRange(%d, %d) failed with %d %lu\n", tests[i].nMin, tests[i].nMax, success, error);
53 ok(newMin == tests[i].nMin, "nMin was changed to %d\n", tests[i].nMin);
54 ok(newMax == tests[i].nMax, "nMax was changed to %d\n", tests[i].nMax);
55 }
56 else
57 {
58 ok(success == FALSE, "SetScrollRange(%d, %d) succeeded with %d\n", tests[i].nMin, tests[i].nMax, success);
59 ok(error == ERROR_INVALID_SCROLLBAR_RANGE, "Error %lu\n", error);
60 ok(newMin == 123, "nMin was changed to %d\n", newMin);
61 ok(newMax == 456, "nMax was changed to %d\n", newMax);
62 }
63 }
64
65 DestroyWindow(hScroll);
66 }