Release 20050930.
[wine/gsoc-2012-control.git] / dlls / comctl32 / tests / updown.c
blobdb1e076c4738d8067cf3079c48c2ed72b9949416
1 /* Unit test suite for updown control.
3 * Copyright 2005 C. Scott Ananian
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.
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.
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
20 #include <assert.h>
21 #include <windows.h>
22 #include <commctrl.h>
23 #include <stdio.h>
25 #include "wine/test.h"
27 static HDC desktopDC;
28 static HINSTANCE hinst;
30 static HWND create_edit_control (DWORD style, DWORD exstyle)
32 HWND handle;
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;
46 static HWND create_updown_control (HWND hWndEdit)
48 HWND hWndUpDown;
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;
71 static void test_updown_control (void)
73 HWND hWndUpDown, hWndEdit;
74 int num;
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);
90 START_TEST(updown)
92 desktopDC=GetDC(NULL);
93 hinst = GetModuleHandleA(NULL);
95 InitCommonControls();
97 test_updown_control();