ReactOS 0.4.16-dev-197-g92996da
SetScrollInfo.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for SetScrollInfo
5 * PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8#include "precomp.h"
9
11{
12 struct
13 {
14 int nMin;
15 int nMax;
16 UINT nPage;
17 int nPos;
18 int nMinResult;
19 int nMaxResult;
20 UINT nPageResult;
21 int nPosResult;
22 } tests[] =
23 {
24 /* min max pg pos min max pg pos */
25 /* [0] */ { 0, 0, 0, 0, 0, 0, 0, 0 },
26 { 0, 0, 1, 1, 0, 0, 1, 0 },
27
28 /* vary nPage only */
29 { 5, 10, 0, 0, 5, 10, 0, 5 },
30 { 5, 10, 1, 0, 5, 10, 1, 5 },
31 { 5, 10, 4, 0, 5, 10, 4, 5 },
32 /* [5] */ { 5, 10, 5, 0, 5, 10, 5, 5 },
33 { 5, 10, 6, 0, 5, 10, 6, 5 },
34 { 5, 10, 7, 0, 5, 10, 6, 5 },
35 { 5, 10, 10, 0, 5, 10, 6, 5 },
36 { 5, 10, 11, 0, 5, 10, 6, 5 },
37 /* [10] */ { 5, 10, 0xffffffff, 0, 5, 10, 6, 5 },
38
39 /* vary nPos only */
40 { 5, 10, 0, 4, 5, 10, 0, 5 },
41 { 5, 10, 0, 5, 5, 10, 0, 5 },
42 { 5, 10, 0, 10, 5, 10, 0, 10 },
43 { 5, 10, 0, 11, 5, 10, 0, 10 },
44 /* [15] */ { 5, 10, 0, -1, 5, 10, 0, 5 },
45 { 5, 10, 0, 0x80000000, 5, 10, 0, 5 },
46 { 5, 10, 0, 0x7fffffff, 5, 10, 0, 10 },
47
48 /* maximum nPos depends on nPage */
49 { 5, 10, 0, 9, 5, 10, 0, 9 },
50 { 5, 10, 0, 10, 5, 10, 0, 10 },
51 /* [20] */ { 5, 10, 0, 11, 5, 10, 0, 10 },
52 { 5, 10, 1, 9, 5, 10, 1, 9 },
53 { 5, 10, 1, 10, 5, 10, 1, 10 },
54 { 5, 10, 1, 11, 5, 10, 1, 10 },
55 { 5, 10, 2, 9, 5, 10, 2, 9 },
56 /* [25] */ { 5, 10, 2, 10, 5, 10, 2, 9 },
57 { 5, 10, 2, 11, 5, 10, 2, 9 },
58 { 5, 10, 3, 9, 5, 10, 3, 8 },
59 { 5, 10, 3, 10, 5, 10, 3, 8 },
60 { 5, 10, 3, 11, 5, 10, 3, 8 },
61
62 /* relation between min and max? */
63 /* min max pg pos min max pg pos */
64 /* [30] */ { 5, 6, 0, 0, 5, 6, 0, 5 },
65 { 5, 5, 0, 0, 5, 5, 0, 5 },
66 { 6, 5, 0, 0, 6, 6, 0, 6 },
67 { 7, 5, 0, 0, 7, 7, 0, 7 },
68 { -2, 0, 0, 0, -2, 0, 0, 0 },
69 /* [35] */ { -2, -1, 0, 0, -2, -1, 0, -1 },
70 { -1, 0, 0, 0, -1, 0, 0, 0 },
71 { -1, -1, 0, 0, -1, -1, 0, -1 },
72 { 0, -1, 0, 0, 0, 0, 0, 0 },
73 { 1, -1, 0, 0, 1, 1, 0, 1 },
74 /* [40] */ { 0x80000000, 0x7fffffff, 0, 0, 0x80000000, 0x7fffffff, 0, 0 },
75 { 0x80000001, 0x7fffffff, 0, 0, 0x80000001, 0x7fffffff, 0, 0 },
76 { 0x80000000, 0x7ffffffe, 0, 0, 0x80000000, 0x7ffffffe, 0, 0 },
77 { 0x7fffffff, 0x80000000, 0, 0, 0x7fffffff, 0x7fffffff, 0, 0x7fffffff },
78 { 0, 0x7fffffff, 0, 0, 0, 0x7fffffff, 0, 0 },
79 /* [45] */ { -1, 0x7fffffff, 0, 0, -1, 0x7fffffff, 0, 0 },
80 { -2, 0x7fffffff, 0, 0, -2, 0x7fffffff, 0, 0 },
81
82 /* What happens to nPage when we have a large range? */
83 { 0x80000000, 0x7fffffff, 1, 5, 0x80000000, 0x7fffffff, 1, 5 },
84 { 0x80000000, 0x7fffffff, 2, 5, 0x80000000, 0x7fffffff, 2, 5 },
85 { 0x80000000, 0x7fffffff, 3, 5, 0x80000000, 0x7fffffff, 2, 5 },
86 /* [50] */ { 0x80000000, 0x7fffffff, 0x7fffffff, 5, 0x80000000, 0x7fffffff, 2, 5 },
87 { 0x80000000, 0x7fffffff, 0x80000000, 5, 0x80000000, 0x7fffffff, 2, 5 },
88 { 0x80000000, 0x7fffffff, 0x80000001, 5, 0x80000000, 0x7fffffff, 2, 5 },
89 { 0x80000000, 0x7fffffff, 0xffffffff, 5, 0x80000000, 0x7fffffff, 2, 5 },
90 { 0x80000001, 0x7fffffff, 1, 5, 0x80000001, 0x7fffffff, 1, 5 },
91 /* [55] */ { 0x80000001, 0x7fffffff, 2, 5, 0x80000001, 0x7fffffff, 2, 5 },
92 { 0x80000001, 0x7fffffff, 3, 5, 0x80000001, 0x7fffffff, 3, 5 },
93 { 0x80000001, 0x7fffffff, 4, 5, 0x80000001, 0x7fffffff, 3, 5 },
94 { 0x80000000, 0x7ffffffe, 1, 5, 0x80000000, 0x7ffffffe, 1, 5 },
95 { 0x80000000, 0x7ffffffe, 2, 5, 0x80000000, 0x7ffffffe, 2, 5 },
96 /* [60] */ { 0x80000000, 0x7ffffffe, 3, 5, 0x80000000, 0x7ffffffe, 3, 5 },
97 { 0x80000000, 0x7ffffffe, 4, 5, 0x80000000, 0x7ffffffe, 3, 5 },
98 { 0, 0x7fffffff, 0x7fffffff, 5, 0, 0x7fffffff, 0x7fffffff, 1 },
99 { 0, 0x7fffffff, 0x80000000, 5, 0, 0x7fffffff, 0x80000000, 0 },
100 { 0, 0x7fffffff, 0x80000001, 5, 0, 0x7fffffff, 0x80000000, 0 },
101 /* [65] */ { 0, 0x7fffffff, 0x80000002, 5, 0, 0x7fffffff, 0x80000000, 0 },
102 { -1, 0x7fffffff, 0x7fffffff, 5, -1, 0x7fffffff, 0x7fffffff, 1 },
103 { -1, 0x7fffffff, 0x80000000, 5, -1, 0x7fffffff, 0x80000000, 0 },
104 { -1, 0x7fffffff, 0x80000001, 5, -1, 0x7fffffff, 0x80000001, -1 },
105 { -1, 0x7fffffff, 0x80000002, 5, -1, 0x7fffffff, 0x80000001, -1 },
106 /* [70] */ { -1, 0x7fffffff, 0x80000003, 5, -1, 0x7fffffff, 0x80000001, -1 },
107 { -2, 0x7fffffff, 0x80000000, 5, -2, 0x7fffffff, 0x80000000, 0 },
108 { -2, 0x7fffffff, 0x80000001, 5, -2, 0x7fffffff, 0x80000000, 0 },
109 { 0xf0000000, 0x7fffffff, 0x90000000, 5, 0xf0000000, 0x7fffffff, 0x70000002, 5 },
110 { 0xf0000000, 0x7fffffff, 0x90000001, 5, 0xf0000000, 0x7fffffff, 0x70000002, 5 },
111 };
112 unsigned i;
114 SCROLLINFO si;
116 int ret;
117
118 hScroll = CreateWindowExW(0, L"SCROLLBAR", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
119 ok(hScroll != NULL, "\n");
120 if (!hScroll)
121 {
122 skip("No scroll bar\n");
123 return;
124 }
125
126 si.cbSize = sizeof(si);
129 ok(success == TRUE, "GetScrollInfo returned %d\n", success);
130 ok(si.nMin == 0, "nMin = %d\n", si.nMin);
131 ok(si.nMax == 0, "nMax = %d\n", si.nMax);
132 ok(si.nPage == 0, "nPage = %u\n", si.nPage);
133 ok(si.nPos == 0, "nPos = %d\n", si.nPos);
134
135 for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
136 {
137 si.cbSize = sizeof(si);
139 si.nMin = tests[i].nMin;
140 si.nMax = tests[i].nMax;
141 si.nPage = tests[i].nPage;
142 si.nPos = tests[i].nPos;
144 ok(ret == tests[i].nPosResult, "[%d] ret = %d, expected %d\n", i, ret, tests[i].nPosResult);
145
146 FillMemory(&si, sizeof(si), 0x55);
147 si.cbSize = sizeof(si);
150 ok(success == TRUE, "[%d] GetScrollInfo returned %d\n", i, success);
151 ok(si.nMin == tests[i].nMinResult, "[%d] nMin = %d, expected %d\n", i, si.nMin, tests[i].nMinResult);
152 ok(si.nMax == tests[i].nMaxResult, "[%d] nMax = %d, expected %d\n", i, si.nMax, tests[i].nMaxResult);
153 ok(si.nPage == tests[i].nPageResult, "[%d] nPage = %u, expected %u\n", i, si.nPage, tests[i].nPageResult);
154 ok(si.nPos == tests[i].nPosResult, "[%d] nPos = %d, expected %d\n", i, si.nPos, tests[i].nPosResult);
155 }
157}
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static struct test_info tests[]
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
static HWND hScroll
Definition: scroll.c:28
int ret
#define success(from, fromstr, to, tostr)
#define SIF_RANGE
Definition: winuser.h:1238
#define SIF_PAGE
Definition: winuser.h:1236
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define SIF_POS
Definition: winuser.h:1237
#define SB_CTL
Definition: winuser.h:554
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
BOOL WINAPI DestroyWindow(_In_ HWND)