test case illustrating updown control deficiency.
C. Scott Ananian
cscott at cscott.net
Tue Mar 15 15:41:54 CST 2005
ChangeLog:
- started a unit test case for the updown control
- added a simple test illustrating a difference in wine/windows behavior.
This is a difference I found while porting 'sd' to winelib (this is in the
Wine applications database).
--scott
Index: dlls/comctl32/tests/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/tests/Makefile.in,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile.in
--- dlls/comctl32/tests/Makefile.in 10 Dec 2004 15:31:38 -0000 1.5
+++ dlls/comctl32/tests/Makefile.in 15 Mar 2005 18:27:53 -0000
@@ -10,7 +10,8 @@ CTESTS = \
imagelist.c \
mru.c \
subclass.c \
- tab.c
+ tab.c \
+ updown.c
@MAKE_TEST_RULES@
--- /dev/null 2005-03-11 20:48:22.619062448 -0500
+++ dlls/comctl32/tests/updown.c 2005-03-15 00:09:50.000000000 -0500
@@ -0,0 +1,98 @@
+/* Unit test suite for updown control.
+ *
+ * Copyright 2005 C. Scott Ananian
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <assert.h>
+#include <windows.h>
+#include <commctrl.h>
+#include <stdio.h>
+
+#include "wine/test.h"
+
+static HDC desktopDC;
+static HINSTANCE hinst;
+
+HWND create_edit_control (DWORD style, DWORD exstyle)
+{
+ HWND handle;
+
+ handle = CreateWindowEx(exstyle,
+ "EDIT",
+ NULL,
+ ES_AUTOHSCROLL | ES_AUTOVSCROLL | style,
+ 10, 10, 300, 300,
+ NULL, NULL, hinst, NULL);
+ assert (handle);
+ if (winetest_interactive)
+ ShowWindow (handle, SW_SHOW);
+ return handle;
+}
+
+HWND create_updown_control (HWND hWndEdit)
+{
+ HWND hWndUpDown;
+
+ // make the control
+ hWndUpDown = CreateWindowEx
+ (0L, UPDOWN_CLASS, NULL,
+ // window styles
+ UDS_SETBUDDYINT | UDS_ALIGNRIGHT |
+ UDS_ARROWKEYS | UDS_NOTHOUSANDS,
+ // placement
+ 0, 0, 8, 8,
+ // parent, etc
+ NULL, NULL, hinst, NULL);
+ assert (hWndUpDown);
+ // set the buddy.
+ SendMessage (hWndUpDown, UDM_SETBUDDY, (LONG)hWndEdit, 0L );
+ // set the range.
+ SendMessage (hWndUpDown, UDM_SETRANGE, 0L, (LPARAM) MAKELONG(32000, 0));
+ // maybe show it.
+ if (winetest_interactive)
+ ShowWindow (hWndUpDown, SW_SHOW);
+ return hWndUpDown;
+}
+
+static void test_updown_control (void)
+{
+ HWND hWndUpDown, hWndEdit;
+ int num;
+
+ hWndEdit = create_edit_control (ES_AUTOHSCROLL | ES_NUMBER, 0);
+ hWndUpDown = create_updown_control (hWndEdit);
+ // before we set a value, it should be '0'
+ num = SendMessage(hWndUpDown, UDM_GETPOS, 0, 0L);
+ ok(num == 0, "Expected 0 got %d\n", num);
+ // set a value, check it.
+ SendMessage(hWndUpDown, UDM_SETPOS, 0L, MAKELONG( 1, 0));
+ num = SendMessage(hWndUpDown, UDM_GETPOS, 0, 0L);
+ ok(num == 1, "Expected 1 got %d\n", num);
+ // okay, done (short set of tests!)
+ DestroyWindow(hWndUpDown);
+ DestroyWindow(hWndEdit);
+}
+
+START_TEST(updown)
+{
+ desktopDC=GetDC(NULL);
+ hinst = GetModuleHandleA(NULL);
+
+ InitCommonControls();
+
+ test_updown_control();
+}
More information about the wine-patches
mailing list