advapi32: Test and implement SystemFunction024/025.
[wine] / dlls / comctl32 / tests / updown.c
1 /* Unit test suite for updown control.
2  *
3  * Copyright 2005 C. Scott Ananian
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #include <assert.h>
21 #include <windows.h>
22 #include <commctrl.h>
23 #include <stdio.h>
24
25 #include "wine/test.h"
26
27 static HDC desktopDC;
28 static HINSTANCE hinst;
29
30 static HWND create_edit_control (DWORD style, DWORD exstyle)
31 {
32     HWND handle;
33
34     handle = CreateWindowEx(exstyle,
35                           "EDIT",
36                           NULL,
37                           ES_AUTOHSCROLL | ES_AUTOVSCROLL | style,
38                           10, 10, 300, 300,
39                           NULL, NULL, hinst, NULL);
40     assert (handle);
41     if (winetest_interactive)
42         ShowWindow (handle, SW_SHOW);
43     return handle;
44 }
45
46 static HWND create_updown_control (HWND hWndEdit)
47 {
48     HWND hWndUpDown;
49
50     /* make the control */
51     hWndUpDown = CreateWindowEx
52         (0L, UPDOWN_CLASS, NULL,
53          /* window styles */
54          UDS_SETBUDDYINT | UDS_ALIGNRIGHT |
55          UDS_ARROWKEYS | UDS_NOTHOUSANDS,
56          /* placement */
57          0, 0, 8, 8, 
58          /* parent, etc */
59          NULL, NULL, hinst, NULL);
60     assert (hWndUpDown);
61     /* set the buddy. */
62     SendMessage (hWndUpDown, UDM_SETBUDDY, (WPARAM)hWndEdit, 0L );
63     /* set the range. */
64     SendMessage (hWndUpDown, UDM_SETRANGE, 0L, (LPARAM) MAKELONG(32000, 0));
65     /* maybe show it. */
66     if (winetest_interactive)
67         ShowWindow (hWndUpDown, SW_SHOW);
68     return hWndUpDown;
69 }
70
71 static void test_updown_control (void)
72 {
73     HWND hWndUpDown, hWndEdit;
74     int num;
75
76     hWndEdit = create_edit_control (ES_AUTOHSCROLL | ES_NUMBER, 0);
77     hWndUpDown = create_updown_control (hWndEdit);
78     /* before we set a value, it should be '0' */
79     num = SendMessage(hWndUpDown, UDM_GETPOS, 0, 0L);
80     ok(num == 0, "Expected 0 got %d\n", num);
81     /* set a value, check it. */
82     SendMessage(hWndUpDown, UDM_SETPOS, 0L, MAKELONG( 1, 0));
83     num = SendMessage(hWndUpDown, UDM_GETPOS, 0, 0L);
84     ok(num == 1, "Expected 1 got %d\n", num);
85     /* okay, done (short set of tests!) */
86     DestroyWindow(hWndUpDown);
87     DestroyWindow(hWndEdit);
88 }
89
90 START_TEST(updown)
91 {
92     desktopDC=GetDC(NULL);
93     hinst = GetModuleHandleA(NULL);
94
95     InitCommonControls();
96
97     test_updown_control();
98 }