White code is not working in Windows 7(64 bit)

Sep 24, 2010 at 9:26 AM

Hi,

we are trying to run our test project using White framework and Gallio/Nunit . When the test project is run using Visual Studio, it is running the test cases but when the project is run thru command line runner for eg: using Gallio.Echo.exe or  Gallio ICarus,  click actions are not performed correctly, it is trying to click the thumbnails(icons on task bar) but not the controls of the application.

 

This seems to be showstopper for me, please look into this issue.

 

Regards,

Subhash

 

Sep 27, 2010 at 8:39 AM

 

Hi

 

there is a known problem with x64 maybe it's the same here

 

try to use nunitx86 version and or build test dll for x86

 

Throndorin

Apr 20, 2011 at 2:44 PM

Some simple TreeNode manipulation failed to work on my machine.. moving the code to a different machine (XP 32 bit) fixed it. Online searches led me to this post. Thanks.

Couldn't find any info regarding this on the forums. I am working on v0.2  - which has this problem. Will this be fixed in the near future ? Is this a fixable problem or an inherent issue that won't be fixed ?

With an increased uptake of 64 bit machines, this should be moving up the priority chain.

May 5, 2011 at 6:18 PM

I have changed white so that it can support both x86 and x64 from a single build.  This allows the same test suite to test both x86 and x64 versions of the application.

 

In Input.cs

 [StructLayout(LayoutKind.Explicit)]
    public struct Input64
    {
        [FieldOffset(0)]
        private int type;
        [FieldOffset(8)]
        private MouseInput mi;
        [FieldOffset(8)]
        private KeyboardInput ki;
        [FieldOffset(8)]
        private HardwareInput hi;

        /// <summary>
        /// Converts a 32bit Input to a 64bit Input
        /// </summary>
        /// <param name="input"></param>
        public Input64(Input input)
        {
            type = input.type;
            mi = input.mi;
            ki = input.ki;
            hi = input.hi;
        }
    }

In Mouse.cs (includes fix for Win7 and 64 bit support)

  [DllImport("user32", EntryPoint = "SendInput")]        private static extern int SendInput64(int numberOfInputs, ref Input64 input, int structSize);

  [DllImport("user32.dll")]        private static extern bool SetCursorPos(int x, int y);

        public virtual Point Location
        {
            get
            {
                var point = new System.Drawing.Point();
                GetCursorPos(ref point);
                return point.ConvertToWindowsPoint();
            }
            set
            {
                if (value.IsInvalid())
                {
                    throw new WhiteException(string.Format("Trying to set location outside the screen. {0}", value));
                }
                SetCursorPos((int)value.X, (int)value.Y);//Win7 Fix
            }
        }

        private static void SendInput(Input input)
        {
            // Added check for 32/64 bit  
            if (IntPtr.Size == 4)
                SendInput(1, ref input, Marshal.SizeOf(typeof(Input)));
            else
            {
                var input64 = new Input64(input);
                SendInput64(1, ref input64, Marshal.SizeOf(typeof(Input)));
            }
        }


In Keyboard.cs

        [DllImport("user32", EntryPoint = "SendInput")]        private static extern int SendInput64(int numberOfInputs, ref Input64 input, int structSize);

        private static void SendInput(Input input)
        {
            // Added check for 32/64 bit   
            if (IntPtr.Size == 4)
                SendInput(1, ref input, Marshal.SizeOf(typeof(Input)));
            else
            {
                var input64 = new Input64(input);
                SendInput64(1, ref input64, Marshal.SizeOf(typeof(Input)));
            }
        }

Dec 16, 2012 at 9:58 AM

What assembly references do I need add for these error?

I added System.Window.Input, but these are still happened. 

The type or namespace name 'MouseInput' could not be found (are you missing a using directive or an assembly reference?) (CS0246)
The type or namespace name 'KeyboardInput' could not be found (are you missing a using directive or an assembly reference?) (CS0246)
The type or namespace name 'HardwareInput' could not be found (are you missing a using directive or an assembly reference?) (CS0246)
The type or namespace name 'Input64' could not be found (are you missing a using directive or an assembly reference?) (CS0246)
The type or namespace name 'Input64' could not be found (are you missing a using directive or an assembly reference?) (CS0246)
The type or namespace name 'Point' could not be found (are you missing a using directive or an assembly reference?) (CS0246)

Coordinator
Jul 28, 2013 at 11:47 AM
Have incorporated these changes. x64 support will be added in the next release of TestStack.White.

https://github.com/TestStack/White/pull/122