-
Notifications
You must be signed in to change notification settings - Fork 2k
Fixed android toolbar icon change #20166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c04b7d7
Fixed android toolbar icon change (#19673)
kubaflo b424b64
Added test sample
jsuarezruiz 9ac046f
More files
jsuarezruiz 5627d38
Added UI Test
jsuarezruiz cb02b5b
Added a UI test (#19950)
kubaflo f38ba26
Apply suggestions from code review
jfversluis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19673.xaml
This file contains hidden or 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,14 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <TabbedPage | ||
| xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue19673" | ||
| xmlns:local="clr-namespace:Maui.Controls.Sample.Issues" | ||
| xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues" | ||
| xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls" | ||
| android:TabbedPage.ToolbarPlacement="Bottom"> | ||
| <local:Issue19673Page1 Title="Page 1" AutomationId="Page1" /> | ||
| <!-- Page 2 has the TabarItem with an Icon --> | ||
| <local:Issue19673Page2 Title="Page 2" AutomationId="Page2" /> | ||
| <local:Issue19673Page3 Title="Page 3" AutomationId="Page3" /> | ||
| </TabbedPage> | ||
15 changes: 15 additions & 0 deletions
15
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19673.xaml.cs
This file contains hidden or 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,15 @@ | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.Controls.Xaml; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
| [XamlCompilation(XamlCompilationOptions.Compile)] | ||
| [Issue(IssueTracker.Github, 19673, "ToolbarItem icon/image doesn't update on page navigation on Android", PlatformAffected.Android, NavigationBehavior.PushAsync)] | ||
| public partial class Issue19673 : TabbedPage | ||
| { | ||
| public Issue19673() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19673Page1.xaml
This file contains hidden or 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" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue19673Page1" | ||
| Title="Page 1"> | ||
| <VerticalStackLayout> | ||
| <Label | ||
| Text="Page 1 - Content" | ||
| VerticalOptions="Center" | ||
| HorizontalOptions="Center" /> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
11 changes: 11 additions & 0 deletions
11
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19673Page1.xaml.cs
This file contains hidden or 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,11 @@ | ||
| using Microsoft.Maui.Controls; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| public partial class Issue19673Page1 : ContentPage | ||
| { | ||
| public Issue19673Page1() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19673Page2.xaml
This file contains hidden or 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 @@ | ||
| <?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.Issue19673Page2" | ||
| Title="Page 2"> | ||
| <ContentPage.ToolbarItems> | ||
| <ToolbarItem | ||
| AutomationId="TestToolbarItem" | ||
| Text="new" | ||
| IconImageSource="shopping_cart.png" | ||
| x:Name="Page2Item" | ||
| Clicked="OnToolbarItemClicked"> | ||
| </ToolbarItem> | ||
| </ContentPage.ToolbarItems> | ||
| <VerticalStackLayout> | ||
| <Label | ||
| x:Name="LabelResult" | ||
| AutomationId="TestLabelResult" | ||
| Text="Page 2 - Content" | ||
| VerticalOptions="Center" | ||
| HorizontalOptions="Center" /> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
16 changes: 16 additions & 0 deletions
16
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19673Page2.xaml.cs
This file contains hidden or 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,16 @@ | ||
| using Microsoft.Maui.Controls; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| public partial class Issue19673Page2 : ContentPage | ||
| { | ||
| public Issue19673Page2() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| void OnToolbarItemClicked(object sender, System.EventArgs e) | ||
| { | ||
| LabelResult.Text = "Success"; | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19673Page3.xaml
This file contains hidden or 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" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue19673Page3" | ||
| Title="Page 3"> | ||
| <VerticalStackLayout> | ||
| <Label | ||
| Text="Page 3 - Content" | ||
| VerticalOptions="Center" | ||
| HorizontalOptions="Center" /> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
11 changes: 11 additions & 0 deletions
11
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19673Page3.xaml.cs
This file contains hidden or 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,11 @@ | ||
| using Microsoft.Maui.Controls; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| public partial class Issue19673Page3 : ContentPage | ||
| { | ||
| public Issue19673Page3() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19950.xaml
This file contains hidden or 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,29 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue19950" | ||
| Title="Issue19950"> | ||
|
|
||
| <TabBar x:Name="tabbar"> | ||
| <ShellContent Title="Tab 1" Icon="groceries.png"> | ||
| <ContentPage> | ||
| <ContentPage.ToolbarItems> | ||
| <ToolbarItem IconImageSource="groceries.png" /> | ||
| </ContentPage.ToolbarItems> | ||
| <Button | ||
| Text="Navigate to tab 2" | ||
| VerticalOptions="Start" | ||
| AutomationId="button" | ||
| Clicked="Button_Clicked"/> | ||
| </ContentPage> | ||
| </ShellContent> | ||
| <ShellContent x:Name="tab2" Route="tab2" Title="Tab 2" Icon="groceries.png"> | ||
| <ContentPage> | ||
| <ContentPage.ToolbarItems> | ||
| <ToolbarItem Text="Toolbar Item" /> | ||
| </ContentPage.ToolbarItems> | ||
| <Label Text="Page 2" AutomationId="labelOnPage2"/> | ||
| </ContentPage> | ||
| </ShellContent> | ||
| </TabBar> | ||
| </Shell> |
38 changes: 38 additions & 0 deletions
38
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19950.xaml.cs
This file contains hidden or 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,38 @@ | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.Controls.Xaml; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [XamlCompilation(XamlCompilationOptions.Compile)] | ||
| [Issue(IssueTracker.Github, 19950, "[Android] ToolbarItem shows incorrect image", PlatformAffected.Android)] | ||
| public class Issue19950Test : ContentPage | ||
| { | ||
| public Issue19950Test() | ||
| { | ||
| Content = new VerticalStackLayout() | ||
| { | ||
| Children = | ||
| { | ||
| new Button() | ||
| { | ||
| Text = "Go To Test", | ||
| AutomationId = "GoToTest", | ||
| Command = new Command(() => Application.Current.MainPage = new Issue19950()) | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| public partial class Issue19950 : Shell | ||
| { | ||
| public Issue19950() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| void Button_Clicked(object sender, System.EventArgs e) | ||
| { | ||
| tabbar.CurrentItem = tab2; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,25 @@ | ||
| using Microsoft.Maui.AppiumTests; | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Controls.AppiumTests.Tests.Issues | ||
| { | ||
| public class Issue19673 : _IssuesUITest | ||
| { | ||
| public Issue19673(TestDevice device) : base(device) { } | ||
|
|
||
| public override string Issue => "ToolbarItem icon/image doesn't update on page navigation on Android"; | ||
|
|
||
| [Test] | ||
| public void ToolbarItemUpdateOnNavigation() | ||
| { | ||
| // 1. Swipe to second page. | ||
| App.WaitForElement("Page1"); | ||
| App.SwipeRightToLeft("Page1"); | ||
|
|
||
| // 2. Verify that the ToolbarItem is rendered. | ||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,35 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.AppiumTests.Issues; | ||
|
|
||
| public class Issue19950 : _IssuesUITest | ||
| { | ||
| public override string Issue => "[Android] ToolbarItem shows incorrect image"; | ||
|
|
||
| public Issue19950(TestDevice device) | ||
| : base(device) | ||
| { } | ||
|
|
||
| [Test] | ||
| public void ToolbarItemShouldShowCorrectImage() | ||
| { | ||
| try | ||
| { | ||
| _ = App.WaitForElement("GoToTest"); | ||
| App.Tap("GoToTest"); | ||
|
|
||
| App.WaitForElement("button"); | ||
| App.Click("button"); | ||
| App.WaitForElement("labelOnPage2"); | ||
|
|
||
| //The test passes if the gorcery icon is visible | ||
| VerifyScreenshot(); | ||
| } | ||
| finally | ||
| { | ||
| Reset(); | ||
| } | ||
| } | ||
| } |
Binary file added
BIN
+25.5 KB
src/Controls/tests/UITests/snapshots/android/ToolbarItemUpdateOnNavigation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test based on the sample from #19673