Bug 2450 - ArgumentNullException thrown in UIView.HitTest when called from UIAutomation
Summary: ArgumentNullException thrown in UIView.HitTest when called from UIAutomation
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2011-12-10 02:34 UTC by Jon Lipsky
Modified: 2011-12-10 11:05 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jon Lipsky 2011-12-10 02:34:24 UTC
Hi,

I'm trying to use UIAutomation to create create a script to do some light UI testing, as well as to automate the capture of screenshots for the next version of the TouchDraw documentation.  I'm running into an issue where I keep getting the following exception:

Dec 10 01:02:46 jlipsky-ipad2 UIKitApplication:com.elevenworks.touchdraw[0x79fe][35494] <Notice>: [FATAL] Argument cannot be null.
Dec 10 01:02:46 jlipsky-ipad2 UIKitApplication:com.elevenworks.touchdraw[0x79fe][35494] <Notice>: Parameter name: uievent
Dec 10 01:02:46 jlipsky-ipad2 UIKitApplication:com.elevenworks.touchdraw[0x79fe][35494] <Notice>: System.ArgumentNullException: Argument cannot be null.
Dec 10 01:02:46 jlipsky-ipad2 UIKitApplication:com.elevenworks.touchdraw[0x79fe][35494] <Notice>: Parameter name: uievent
Dec 10 01:02:46 jlipsky-ipad2 UIKitApplication:com.elevenworks.touchdraw[0x79fe][35494] <Notice>:   at MonoTouch.UIKit.UIView.HitTest (PointF point, MonoTouch.UIKit.UIEvent uievent) [0x00000] in <filename unknown>:0 

It appears the MonoTouch UIView.HitTest(point, uievent) method won't allow a null argument for "uievent"; however this is what UIAutomation is passing to the HitTest method when you issue a "tap()" command.  Here's an example of a UIAutomation call that causes this to happen:

target.frontMostApp().mainWindow().buttons()[13].tap();

The way to reproduce this, is to create a UIView, override HitTest with something like this:

        public override UIView HitTest (PointF point, UIEvent uievent)
        {
            if (base.HitTest (point, uievent) != null)
            {
                return this;
            }
            return null;
        }

and then to setup a UIAutomation script to tap that UIView.
Comment 1 Sebastien Pouliot 2011-12-10 10:34:36 UTC
You're right, according to [1] the `uievent` parameter might be null.

<quote>
If you are calling this method from outside your event-handling code, you may specify nil.
</quote>

[1] http://developer.apple.com/library/IOs/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/hitTest:withEvent:
Comment 2 Sebastien Pouliot 2011-12-10 11:05:20 UTC
Fixed (both HitTest and PointInside methods).
They will be in MT 5.1.2+ (next beta) and MD 5.0.5+ (not 5.0.4).
Thanks for the report!