diff options
author | Stephane Delcroix <stephane@delcroix.org> | 2016-07-19 01:30:08 +0200 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-07-18 16:30:08 -0700 |
commit | d52f110d78cc66441c32520acedc752cd949c0ac (patch) | |
tree | fab1d3932c0b195ae0fb10b2ff5fb0edee59fd6a /Xamarin.Forms.Xaml.UnitTests/EventsConnection.xaml.cs | |
parent | e36816810fb0c29fd5607e9cbb2102d64c46b23f (diff) | |
download | xamarin-forms-d52f110d78cc66441c32520acedc752cd949c0ac.tar.gz xamarin-forms-d52f110d78cc66441c32520acedc752cd949c0ac.tar.bz2 xamarin-forms-d52f110d78cc66441c32520acedc752cd949c0ac.zip |
[XamlC] correctly resolve override of virtual event handlers (#247)
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests/EventsConnection.xaml.cs')
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/EventsConnection.xaml.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/EventsConnection.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/EventsConnection.xaml.cs index 5727693e..3552fa21 100644 --- a/Xamarin.Forms.Xaml.UnitTests/EventsConnection.xaml.cs +++ b/Xamarin.Forms.Xaml.UnitTests/EventsConnection.xaml.cs @@ -71,6 +71,12 @@ namespace Xamarin.Forms.Xaml.UnitTests asyncPrivateClicked++; } + int baseForVirtualClicked; + protected virtual void HandleVirtualClicked(object sender, EventArgs e) + { + baseForVirtualClicked++; + } + [TestFixture] public class Tests { @@ -113,6 +119,37 @@ namespace Xamarin.Forms.Xaml.UnitTests layout.elementwithAsyncprivateHandler.SendClicked (); Assert.AreEqual (1, layout.asyncPrivateClicked); } + + [TestCase(false)] + [TestCase(true)] + public void TestVirtualHandler(bool useCompiledXaml) + { + var layout = new SubForEvents(useCompiledXaml); + Assert.AreEqual(0, layout.baseForVirtualClicked); + Assert.AreEqual(0, layout.overrideClicked); + layout.elementWithVirtualHandler.SendClicked(); + Assert.AreEqual(0, layout.baseForVirtualClicked); + Assert.AreEqual(1, layout.overrideClicked); + } + } + } + + public class SubForEvents : EventsConnection + { + public SubForEvents(bool useCompiledXaml) : base(useCompiledXaml) + { + } + + public int overrideClicked; + protected override void HandleVirtualClicked(object sender, EventArgs e) + { + overrideClicked++; + } + +#pragma warning disable 1998 // considered for removal + async void HandleClickedPrivateAsync(object sender, EventArgs e) +#pragma warning restore 1998 + { } } }
\ No newline at end of file |