TestStack/White — pull request #182 by ivan-danilov (2013-12-27 20:12:01+00:00)
Title: Fix: problem with cursors that are not the same on my OS as hardcoded in the MouseCursor class

Hi.

I was investigating why White is often very slow to get items (WPF application) and found out that it was waiting inside `Window.HourGlassWait()` method. Adding some debug logging shown such thing:

```
[Debug] 'TestStack.White.UIItems.UIItem' HourGlassWait: current cursor is 65543, waiting again
[Debug] 'TestStack.White.UIItems.UIItem' HourGlassWait: current cursor is 65543, waiting again
[Debug] 'TestStack.White.UIItems.UIItem' HourGlassWait: current cursor is 65543, waiting again
[Debug] 'TestStack.White.UIItems.UIItem' HourGlassWait: current cursor is 65543, waiting again
```

and yet several dozens of such lines after what timeout happened.

[Here](https://github.com/TestStack/White/blob/master/src/TestStack.White/InputDevices/MouseCursor.cs#L12) HCURSOR=65543 is defined as `SilverlightWait`. But we don't use Silverlight at all. Trying to figure out what is happening I've written such piece:

```csharp
// this is from http://www.pinvoke.net/default.aspx/user32/LoadCursor.html
[DllImport("user32.dll")]
static extern IntPtr LoadCursor(IntPtr hInstance, IDC_STANDARD_CURSORS lpCursorName);

// this is from http://pinvoke.net/default.aspx/Constants/IDC_.html
enum IDC_STANDARD_CURSORS
{
IDC_ARROW = 32512,
IDC_IBEAM = 32513,
IDC_WAIT = 32514,
IDC_CROSS = 32515,
IDC_UPARROW = 32516,
IDC_SIZE = 32640,
IDC_ICON = 32641,
IDC_SIZENWSE = 32642,
IDC_SIZENESW = 32643,
IDC_SIZEWE = 32644,
IDC_SIZENS = 32645,
IDC_SIZEALL = 32646,
IDC_NO = 32648,
IDC_HAND = 32649,
IDC_APPSTARTING = 32650,
IDC_HELP = 32651
}

var values = Enum.GetValues(typeof (IDC_STANDARD_CURSORS)).Cast().ToArray();
foreach (var idcStandardCursor in values)
{
var c = LoadCursor(IntPtr.Zero, idcStandardCursor);
Console.WriteLine("{0} = {1}", idcStandardCursor.ToString(), c.ToInt32());
}
```

And the result was:

```
IDC_ARROW = 65543
IDC_IBEAM = 65545
IDC_WAIT = 65547
IDC_CROSS = 65549
IDC_UPARROW = 65551
IDC_SIZE = 0
IDC_ICON = 0
IDC_SIZENWSE = 65553
IDC_SIZENESW = 65555
IDC_SIZEWE = 65557
IDC_SIZENS = 65559
IDC_SIZEALL = 65561
IDC_NO = 65563
IDC_HAND = 65571
IDC_APPSTARTING = 65565
IDC_HELP = 65567
```

It seems that in my OS 65543 is precisely "normal" arrow cursor. And `Window.HourGlassWait()` waits until something else found. Not to mention that waiting results in failure.
By the way, other cursors in the [MouseCursor.cs](https://github.com/TestStack/White/blob/master/src/TestStack.White/InputDevices/MouseCursor.cs) are also not coincide with my OS values.

Now, this pull request is more a question then ready-to-merge code, because I don't know what to replace Silverlight values with, so just commented them. But overall this code make unit-tests of White pass on my machine and my real code work much-much faster (I believe that before I was waiting for a timeout on almost each `WaitHourGlass()` call).