-
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.
[release/8.0.1xx-sr9] NullReferenceException when setting BarBackgrou…
…ndColor for a NavigationPage - fix (#25251) * Added a null check * Added a UI test * Removed an xaml file for ui test * Update NavigationPageToolbar.cs * Improvements * Update NavigationPageToolbar.cs --------- Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
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,40 @@ | ||
namespace Maui.Controls.Sample.Issues; | ||
using Microsoft.Maui.Controls; | ||
|
||
[Issue(IssueTracker.Github, 25114, "NullReferenceException when setting BarBackgroundColor for a NavigationPage", PlatformAffected.All)] | ||
public class Issue25114Flyout : FlyoutPage | ||
{ | ||
public Issue25114Flyout() | ||
{ | ||
var navPage = new NavigationPage(new Issue25114()); | ||
navPage.SetDynamicResource(NavigationPage.BarBackgroundColorProperty, "Primary"); | ||
Detail = navPage; | ||
Flyout = new ContentPage | ||
{ | ||
Title = "Flyout" | ||
}; | ||
} | ||
} | ||
|
||
public class Issue25114 : ContentPage | ||
{ | ||
public Issue25114() | ||
{ | ||
Content = new Button() | ||
{ | ||
AutomationId = "button", | ||
HeightRequest = 100, | ||
Text = "Change the Navigation Bar's Color", | ||
Command = new Command(() => | ||
{ | ||
Application.Current.Resources["Primary"] = "#0000FF"; | ||
}) | ||
}; | ||
} | ||
|
||
protected override void OnAppearing() | ||
{ | ||
base.OnAppearing(); | ||
Application.Current.Resources["Primary"] = "#00FF00"; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25114.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,23 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
||
public class Issue25114 : _IssuesUITest | ||
{ | ||
public Issue25114(TestDevice testDevice) : base(testDevice) | ||
{ | ||
} | ||
|
||
public override string Issue => "NullReferenceException when setting BarBackgroundColor for a NavigationPage"; | ||
|
||
[Test] | ||
[Category(UITestCategories.FlyoutPage)] | ||
public void NoExceptionShouldBeThrownWhenChangingNavigationBarColor() | ||
{ | ||
App.WaitForElement("button"); | ||
App.Tap("button"); | ||
} | ||
|
||
} |