-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
288 additions
and
6 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/Controls/samples/Controls.Sample.UITests/Issues/Issue21846.xaml
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,17 @@ | ||
<?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" | ||
x:Class="Maui.Controls.Sample.Issues.Issue21846" | ||
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues"> | ||
<ScrollView> | ||
<VerticalStackLayout | ||
Padding="30,0" | ||
Spacing="25"> | ||
<Button | ||
x:Name="TestButton" | ||
AutomationId="OpenModalButton" | ||
Text="Open" | ||
Clicked="OnButtonClicked" /> | ||
</VerticalStackLayout> | ||
</ScrollView> | ||
</ContentPage> |
22 changes: 22 additions & 0 deletions
22
src/Controls/samples/Controls.Sample.UITests/Issues/Issue21846.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,22 @@ | ||
using System; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 21846, "Fix crash closing Popup with WebView", PlatformAffected.iOS)] | ||
public partial class Issue21846 : ContentPage | ||
{ | ||
public Issue21846() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
async void OnButtonClicked(object sender, System.EventArgs e) | ||
{ | ||
await Navigation.PushModalAsync(new Issue21846Modal()); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Controls/samples/Controls.Sample.UITests/Issues/Issue21846Modal.xaml
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" | ||
x:Class="Maui.Controls.Sample.Issues.Issue21846Modal" | ||
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues"> | ||
<ScrollView> | ||
<Grid | ||
RowDefinitions="*, Auto" | ||
Padding="30,0"> | ||
<WebView | ||
x:Name="TestWebView" | ||
Source="https://www.microsoft.com"/> | ||
<Button | ||
Grid.Row="1" | ||
AutomationId="CloseModalButton" | ||
Text="Close" | ||
Clicked="OnButtonClicked" /> | ||
</Grid> | ||
</ScrollView> | ||
</ContentPage> |
34 changes: 34 additions & 0 deletions
34
src/Controls/samples/Controls.Sample.UITests/Issues/Issue21846Modal.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,34 @@ | ||
using System; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
public partial class Issue21846Modal : ContentPage | ||
{ | ||
public Issue21846Modal() | ||
{ | ||
InitializeComponent(); | ||
|
||
BindingContext = this; | ||
} | ||
|
||
async void OnButtonClicked(object sender, System.EventArgs e) | ||
{ | ||
if (TestWebView is IElement visualElement) | ||
{ | ||
if (visualElement.Handler != null) | ||
{ | ||
if (visualElement.Handler is IDisposable disposableHandler) | ||
disposableHandler.Dispose(); | ||
|
||
visualElement.Handler.DisconnectHandler(); | ||
} | ||
} | ||
|
||
await Navigation.PopModalAsync(); | ||
} | ||
} | ||
} |
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
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
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,28 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue21846 : _IssuesUITest | ||
{ | ||
public Issue21846(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
public override string Issue => "Fix crash closing Popup with WebView"; | ||
|
||
[Test] | ||
[Category(UITestCategories.WebView)] | ||
public void WebViewNoCrashPopup() | ||
{ | ||
this.IgnoreIfPlatforms([TestDevice.Android, TestDevice.Windows]); | ||
|
||
App.WaitForElement("OpenModalButton"); | ||
App.Click("OpenModalButton"); | ||
|
||
App.WaitForElement("CloseModalButton"); | ||
App.Click("CloseModalButton"); | ||
} | ||
} | ||
} |
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui21757"> | ||
<Color x:Key="Gray-200">#C8C8C8</Color> | ||
<Style x:Key="A" TargetType="BoxView"> | ||
<Setter Property="Color" Value="{StaticResource Gray-200}" /> | ||
</Style> | ||
<Style x:Key="B" TargetType="{x:Type BoxView}"> | ||
<Setter Property="Color" Value="{StaticResource Gray-200}" /> | ||
</Style> | ||
</ResourceDictionary> |
60 changes: 60 additions & 0 deletions
60
src/Controls/tests/Xaml.UnitTests/Issues/Maui21757.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,60 @@ | ||
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 Maui21757 | ||
{ | ||
public Maui21757() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public Maui21757(bool useCompiledXaml) | ||
{ | ||
//this stub will be replaced at compile time | ||
} | ||
|
||
[TestFixture] | ||
class Test | ||
{ | ||
[SetUp] | ||
public void Setup() | ||
{ | ||
Application.SetCurrentApplication(new MockApplication()); | ||
DispatcherProvider.SetCurrent(new DispatcherProviderStub()); | ||
} | ||
|
||
[TearDown] public void TearDown() => AppInfo.SetCurrent(null); | ||
|
||
[Test] | ||
public void TypeLiteralAndXTypeCanBeUsedInterchangeably([Values(false, true)] bool useCompiledXaml) | ||
{ | ||
var resourceDictionary = new Maui21757(useCompiledXaml); | ||
|
||
var styleA = resourceDictionary["A"] as Style; | ||
Assert.NotNull(styleA); | ||
Assert.That(styleA.TargetType, Is.EqualTo(typeof(BoxView))); | ||
Assert.That(styleA.Setters[0].Property, Is.EqualTo(BoxView.ColorProperty)); | ||
Assert.That(styleA.Setters[0].Value, Is.EqualTo(Color.FromArgb("#C8C8C8"))); | ||
|
||
var styleB = resourceDictionary["B"] as Style; | ||
Assert.NotNull(styleB); | ||
Assert.That(styleB.TargetType, Is.EqualTo(typeof(BoxView))); | ||
Assert.That(styleB.Setters[0].Property, Is.EqualTo(BoxView.ColorProperty)); | ||
Assert.That(styleB.Setters[0].Value, Is.EqualTo(Color.FromArgb("#C8C8C8"))); | ||
} | ||
} | ||
} |
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,9 @@ | ||
<?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" | ||
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui21774"> | ||
<StackLayout> | ||
<Label x:Name="label0" TextColor="{DynamicResource labelColor}"/> | ||
<Label x:Name="label1" TextColor="{AppThemeBinding Light=LimeGreen, Dark=HotPink}"/> | ||
</StackLayout> | ||
</ContentPage> |
69 changes: 69 additions & 0 deletions
69
src/Controls/tests/Xaml.UnitTests/Issues/Maui21774.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,69 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
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 Maui21774 | ||
{ | ||
public Maui21774() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public Maui21774(bool useCompiledXaml) | ||
{ | ||
//this stub will be replaced at compile time | ||
} | ||
|
||
[TestFixture] | ||
class Test | ||
{ | ||
[SetUp] | ||
public void Setup() | ||
{ | ||
Application.SetCurrentApplication(new MockApplication()); | ||
DispatcherProvider.SetCurrent(new DispatcherProviderStub()); | ||
} | ||
|
||
[TearDown] public void TearDown() => AppInfo.SetCurrent(null); | ||
|
||
[Test] | ||
public void AppThemeChangeOnUnparentedPage([Values(false, true)] bool useCompiledXaml) | ||
{ | ||
Application.Current.Resources.Add("labelColor", Colors.LimeGreen); | ||
Application.Current.UserAppTheme = AppTheme.Light; | ||
var page = new Maui21774(useCompiledXaml); | ||
Application.Current.MainPage = page; | ||
|
||
Assert.That(page.label0.TextColor, Is.EqualTo(Colors.LimeGreen)); | ||
Assert.That(page.label1.TextColor, Is.EqualTo(Colors.LimeGreen)); | ||
|
||
//unparent the page, change the resource and the theme | ||
Application.Current.MainPage = null; | ||
Application.Current.Resources["labelColor"] = Colors.HotPink; | ||
Application.Current.UserAppTheme = AppTheme.Dark; | ||
//labels should not change | ||
Assert.That(page.label0.TextColor, Is.EqualTo(Colors.LimeGreen)); | ||
Assert.That(page.label1.TextColor, Is.EqualTo(Colors.LimeGreen)); | ||
|
||
//reparent the page | ||
Application.Current.MainPage = page; | ||
//labels should change | ||
Assert.That(page.label0.TextColor, Is.EqualTo(Colors.HotPink)); | ||
Assert.That(page.label1.TextColor, Is.EqualTo(Colors.HotPink)); | ||
} | ||
} | ||
} |
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