comtctl32 : updown : Getter and Setter Tests for Updown control

Leslie Choong septikus at gmail.com
Mon Feb 12 02:43:26 CST 2007


Thanks for the input, I've added the expect() macro, corrected some
spelling mistakes. Let me know what else I can do.
-Leslie

On 2/11/07, Dan Kegel <dank06 at kegel.com> wrote:
> I haven't looked at what James was talking about, but I noticed three things:
>
> You have a typo 'sohuld'.
>
> You should use the same filename as before, but increment the number
> in the filename.
>
> You might consider using the expect() macro I've been encouraging
> the other cs130 students to use, it makes the repeated ok() calls a bit
> more readable (IMHO, we'll see if others agree).
> - Dan
>
> On 2/11/07, Leslie Choong <septikus at gmail.com> wrote:
> > Hey there, I've made the changes so that the return value is not
> > stored unnecessarily. I've also added comments explaining why. Let me
> > know what you think.
> > -Leslie
> >
> > On 2/11/07, Leslie Choong <septikus at gmail.com> wrote:
> > > Thanks for the input. UDM_SETRANGE has no return value according to
> > > MSDN so I'll remove those assignments.
> > >
> > > On 2/11/07, James Hawkins <truiken at gmail.com> wrote:
> > > > On 2/10/07, Leslie Choong <septikus at gmail.com> wrote:
> > > > > Hi there, My name is Leslie Choong and I am currently finishing up my
> > > > > under graduate work at UCLA. This patch is being sent as part of the
> > > > > coursework for CS 130 : Software Engineering. Please take a look and
> > > > > let me know if you have any suggestions or comments for change.
> > > > > Thanks!
> > > > > -Leslie Choong
> > > > >
> > > >
> > > > +    /* Set Range from 0 to 100 */
> > > > +    r = SendMessage(updown, UDM_SETRANGE, 0 , MAKELONG(100,0) );
> > > > +    r= SendMessage(updown, UDM_GETRANGE, 0,0);
> > > >
> > > > If you're not going to check the first return value, then take out the
> > > > 'r =', else it seems like you're missing a test.  On the other hand,
> > > > why don't you test the return value?
> > > >
> > > > --
> > > > James Hawkins
> > > >
> > >
> >
> >
>
>
> --
> Wine for Windows ISVs: http://kegel.com/wine/isv
>
-------------- next part --------------
From 538f7ffdac284ff15daafa72c4209a24221768e8 Mon Sep 17 00:00:00 2001
From: U-SEPTIKUS\Leslie <septikus at gmail.com>
Date: Sun, 11 Feb 2007 20:42:03 -0800
Subject: [PATCH] Added Getter/Setter Tests for Updown Common Control

---
 dlls/comctl32/tests/updown.c |  177 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 177 insertions(+), 0 deletions(-)

diff --git a/dlls/comctl32/tests/updown.c b/dlls/comctl32/tests/updown.c
diff --git a/dlls/comctl32/tests/updown.c b/dlls/comctl32/tests/updown.c
index e0b8131..f93e840 100644
--- a/dlls/comctl32/tests/updown.c
+++ b/dlls/comctl32/tests/updown.c
@@ -2,6 +2,7 @@
  *
  * Copyright 2005 C. Scott Ananian
  * Copyright (C) 2007 James Hawkins
+ * Copyright (C) 2007 Leslie Choong
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -51,6 +52,8 @@
 
 #include "wine/test.h"
 
+#define expect(expected,got) ok(got == expected, "Expected %d, got %d\n", expected, got)
+
 #define NUM_MSG_SEQUENCES   3
 #define PARENT_SEQ_INDEX    0
 #define EDIT_SEQ_INDEX      1
@@ -500,6 +503,174 @@ static HWND create_updown_control()
     return updown;
 }
 
+static void test_updown_pos(void)
+{
+    int r;
+
+    /* Set Range from 0 to 100 */
+    /* No need to check first return as UDM_SETRANGE does not use it */
+    SendMessage(updown, UDM_SETRANGE, 0 , MAKELONG(100,0) );
+    r= SendMessage(updown, UDM_GETRANGE, 0,0);
+    expect(100,LOWORD(r));
+    expect(0,HIWORD(r));
+
+    /* Set the position to 5, return is not checked as it was set before func call */
+    SendMessage(updown, UDM_SETPOS, 0 , MAKELONG(5,0) );
+    /* Since UDM_SETBUDDYINT was not set at creation HIWORD(r) will always be 1 as a return from UDM_GETPOS */
+    /* Get the position, which should be 5 */
+    r = SendMessage(updown, UDM_GETPOS, 0 , 0 );
+    expect(5,LOWORD(r));
+    expect(1,HIWORD(r));
+
+    /* Set the position to 0, return should be 5 */
+    r = SendMessage(updown, UDM_SETPOS, 0 , MAKELONG(0,0) );
+    expect(5,r);
+    /* Get the position, which should be 0 */
+    r = SendMessage(updown, UDM_GETPOS, 0 , 0 );
+    expect(0,LOWORD(r));
+    expect(1,HIWORD(r));
+
+    /* Set the position to -1, return should be 0 */
+    r = SendMessage(updown, UDM_SETPOS, 0 , MAKELONG(-1,0) );
+    expect(0,r);
+    /* Get the position, which should be 0 */
+    r = SendMessage(updown, UDM_GETPOS, 0 , 0 );
+    expect(0,LOWORD(r));
+    expect(1,HIWORD(r));
+
+    /* Set the position to 100, return should be 0 */
+    r = SendMessage(updown, UDM_SETPOS, 0 , MAKELONG(100,0) );
+    expect(0,r);
+    /* Get the position, which should be 100 */
+    r = SendMessage(updown, UDM_GETPOS, 0 , 0 );
+    expect(100,LOWORD(r));
+    expect(1,HIWORD(r));
+
+    /* Set the position to 101, return should be 100 */
+    r = SendMessage(updown, UDM_SETPOS, 0 , MAKELONG(101,0) );
+    expect(100,r);
+    /* Get the position, which should be 100 */
+    r = SendMessage(updown, UDM_GETPOS, 0 , 0 );
+    expect(100,LOWORD(r));
+    expect(1,HIWORD(r));
+}
+
+static void test_updown_pos32(void)
+{
+    int r;
+    int low, high;
+
+    /* Set the position to 0 to 1000 */
+    /* No need to check first return as UDM_SETRANGE32 does not use it */
+    SendMessage(updown, UDM_SETRANGE32, 0 , 1000 );
+
+    r = SendMessage(updown, UDM_GETRANGE32, (WPARAM) &low , (LPARAM) &high );
+    expect(0,low);
+    expect(1000,high);
+
+    /* Set position to 500, don't check return since it is unset*/
+    SendMessage(updown, UDM_SETPOS32, 0 , 500 );
+
+    /* Since UDM_SETBUDDYINT was not set at creation bRet will always be true as a return from UDM_GETPOS32 */
+
+    r = SendMessage(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
+    expect(500,r);
+    ok(high == 1 , "Expected 0, got %d\n", high);
+
+    /* Set position to 0, return should be 500 */
+    r = SendMessage(updown, UDM_SETPOS32, 0 , 0 );
+    expect(500,r);
+    r = SendMessage(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
+    expect(0,r);
+    expect(1,high);
+
+    /* Set position to -1 which should become 0, return should be 0 */
+    r = SendMessage(updown, UDM_SETPOS32, 0 , -1 );
+    expect(0,r);
+    r = SendMessage(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
+    expect(0,r);
+    expect(1,high);
+
+    /* Set position to 1000, return should be 0 */
+    r = SendMessage(updown, UDM_SETPOS32, 0 , 1000 );
+    expect(0,r);
+    r = SendMessage(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
+    expect(1000,r);
+    expect(1,high);
+
+    /* Set position to 1001 which should become 1000, return should be 1000 */
+    r = SendMessage(updown, UDM_SETPOS32, 0 , 1001 );
+    expect(1000,r);
+    r = SendMessage(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
+    expect(1000,r);
+    expect(1,high);
+}
+
+static void test_updown_buddy(void)
+{
+    HWND buddyReturn;
+
+    buddyReturn = (HWND)SendMessage(updown, UDM_GETBUDDY, 0 , 0 );
+    expect((int)edit,(int)buddyReturn);
+}
+
+static void test_updown_base(void)
+{
+    int r;
+
+    /* return not checked since previous value is not known at start */
+    SendMessage(updown, UDM_SETBASE, 10 , 0);
+    r = SendMessage(updown, UDM_GETBASE, 0 , 0);
+    expect(10,r);
+
+    /* Set base to an invalid value, should return 0 and stay at 10 */
+    r = SendMessage(updown, UDM_SETBASE, 80 , 0);
+    expect(0,r);
+    r = SendMessage(updown, UDM_GETBASE, 0 , 0);
+    expect(10,r);
+
+    /* Set base to 16 now, should get 16 as the return */
+    r = SendMessage(updown, UDM_SETBASE, 16 , 0);
+    expect(10,r);
+    r = SendMessage(updown, UDM_GETBASE, 0 , 0);
+    expect(16,r);
+
+    /* Set base to an invalid value, should return 0 and stay at 16 */
+    r = SendMessage(updown, UDM_SETBASE, 80 , 0);
+    expect(0,r);
+    r = SendMessage(updown, UDM_GETBASE, 0 , 0);
+    expect(16,r);
+
+    /* Set base back to 10, return should be 16 */
+    r = SendMessage(updown, UDM_SETBASE, 10 , 0);
+    expect(16,r);
+    r = SendMessage(updown, UDM_GETBASE, 0 , 0);
+    expect(10,r);
+}
+
+static void test_updown_unicode(void)
+{
+    int r;
+
+    /* Set it to ANSI, don't check return as we don't know previous state */
+    SendMessage(updown, UDM_SETUNICODEFORMAT, 0 , 0);
+    r = SendMessage(updown, UDM_GETUNICODEFORMAT, 0 , 0);
+    expect(0,r);
+
+    /* Now set it to Unicode format */
+    r = SendMessage(updown, UDM_SETUNICODEFORMAT, 1 , 0);
+    expect(0,r);
+    r = SendMessage(updown, UDM_GETUNICODEFORMAT, 0 , 0);
+    expect(1,r);
+
+    /* And now set it back to ANSI */
+    r = SendMessage(updown, UDM_SETUNICODEFORMAT, 0 , 0);
+    expect(1,r);
+    r = SendMessage(updown, UDM_GETUNICODEFORMAT, 0 , 0);
+    expect(0,r);
+}
+
+
 static void test_create_updown_control(void)
 {
     CHAR text[MAX_PATH];
@@ -528,6 +699,12 @@ static void test_create_updown_control(void)
     ok_sequence(EDIT_SEQ_INDEX, get_edit_text_seq, "get edit text", FALSE);
 
     flush_sequences();
+
+    test_updown_pos();
+    test_updown_pos32();
+    test_updown_buddy();
+    test_updown_base();
+    test_updown_unicode();
 }
 
 START_TEST(updown)
-- 
1.4.4.4


More information about the wine-devel mailing list