-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C] avoid NRE on null GesturRecognizer
- fixes #24900
- Loading branch information
1 parent
0fce6c7
commit 4dcd338
Showing
3 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests" | ||
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui24900"> | ||
<Border> | ||
<Border.GestureRecognizers> | ||
<OnPlatform x:TypeArguments="GestureRecognizer"> | ||
<OnPlatform.Platforms> | ||
<On Platform="Android"> | ||
<TapGestureRecognizer Tapped="Header_Tapped" /> | ||
</On> | ||
<!-- <On Platform="WinUI"> | ||
<TapGestureRecognizer Tapped="Header_Tapped" /> | ||
</On> --> | ||
</OnPlatform.Platforms> | ||
</OnPlatform> | ||
</Border.GestureRecognizers> | ||
</Border> | ||
</ContentPage> |
65 changes: 65 additions & 0 deletions
65
src/Controls/tests/Xaml.UnitTests/Issues/Maui24900.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.Linq; | ||
using Microsoft.Maui.ApplicationModel; | ||
using Microsoft.Maui.Controls.Core.UnitTests; | ||
using Microsoft.Maui.Controls.Shapes; | ||
using Microsoft.Maui.Devices; | ||
using Microsoft.Maui.Dispatching; | ||
|
||
using Microsoft.Maui.Graphics; | ||
using Microsoft.Maui.UnitTests; | ||
using NUnit.Framework; | ||
|
||
namespace Microsoft.Maui.Controls.Xaml.UnitTests; | ||
|
||
public partial class Maui24900 : ContentPage | ||
{ | ||
public Maui24900() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public Maui24900(bool useCompiledXaml) | ||
{ | ||
//this stub will be replaced at compile time | ||
} | ||
|
||
void Header_Tapped(object sender, TappedEventArgs e) | ||
{ | ||
|
||
} | ||
|
||
[TestFixture] | ||
class Test | ||
{ | ||
MockDeviceInfo mockDeviceInfo; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
Application.SetCurrentApplication(new MockApplication()); | ||
DeviceInfo.SetCurrent(mockDeviceInfo = new MockDeviceInfo()); | ||
DispatcherProvider.SetCurrent(new DispatcherProviderStub()); | ||
} | ||
|
||
|
||
[TearDown] public void TearDown() | ||
{ | ||
AppInfo.SetCurrent(null); | ||
DeviceInfo.SetCurrent(null); | ||
} | ||
|
||
[Test] | ||
public void OnPlatformDownNotThrow([Values(false, true)] bool useCompiledXaml) | ||
{ | ||
mockDeviceInfo.Platform = DevicePlatform.WinUI; | ||
Assert.DoesNotThrow(()=> new Maui24900(useCompiledXaml)); | ||
|
||
|
||
|
||
} | ||
} | ||
} |