Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" />
Copy link
Copy Markdown
Contributor

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

<!-- Page 2 has the TabarItem with an Icon -->
<local:Issue19673Page2 Title="Page 2" AutomationId="Page2" />
<local:Issue19673Page3 Title="Page 3" AutomationId="Page3" />
</TabbedPage>
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();
}
}
}
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>
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();
}
}
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>
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";
}
}
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>
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();
}
}
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>
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ static void UpdateMenuItem(AToolbar toolbar,
return;

menuitem.SetTitle(newTitle);
menuitem.SetIcon(null);
}

menuitem.SetEnabled(item.IsEnabled);
Expand Down
25 changes: 25 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue19673.cs
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();
}
}
}
35 changes: 35 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue19950.cs
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();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions src/TestUtils/src/UITest.Appium/Actions/AppiumScrollActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ CommandResponse ScrollUp(IDictionary<string, object> parameters)

static void ScrollToLeft(AppiumDriver driver, AppiumElement element, ScrollStrategy strategy, double swipePercentage, int swipeSpeed, bool withInertia = true)
{
var position = element is not null ? element.Location : System.Drawing.Point.Empty;
var size = element is not null ? element.Size : driver.Manage().Window.Size;
var position = element is not null ? element.Location : System.Drawing.Point.Empty;
var size = element is not null ? element.Size : driver.Manage().Window.Size;

int startX = (int)(position.X + (size.Width * 0.05));
int startX = (int)(position.X + (size.Width * 0.05));
int startY = position.Y + size.Height / 2;

int endX = (int)(position.X + (size.Width * swipePercentage));
Expand All @@ -164,10 +164,10 @@ static void ScrollToLeft(AppiumDriver driver, AppiumElement element, ScrollStrat

static void ScrollToDown(AppiumDriver driver, AppiumElement element, ScrollStrategy strategy, double swipePercentage, int swipeSpeed, bool withInertia = true)
{
var position = element is not null ? element.Location : System.Drawing.Point.Empty;
var size = element is not null ? element.Size : driver.Manage().Window.Size;
var position = element is not null ? element.Location : System.Drawing.Point.Empty;
var size = element is not null ? element.Size : driver.Manage().Window.Size;

int startX = position.X + size.Width / 2;
int startX = position.X + size.Width / 2;
int startY = (int)(position.Y + (size.Height * swipePercentage));

int endX = startX;
Expand All @@ -185,10 +185,10 @@ static void ScrollToDown(AppiumDriver driver, AppiumElement element, ScrollStrat

static void ScrollToRight(AppiumDriver driver, AppiumElement element, ScrollStrategy strategy, double swipePercentage, int swipeSpeed, bool withInertia = true)
{
var position = element is not null ? element.Location : System.Drawing.Point.Empty;
var size = element is not null ? element.Size : driver.Manage().Window.Size;
var position = element is not null ? element.Location : System.Drawing.Point.Empty;
var size = element is not null ? element.Size : driver.Manage().Window.Size;

int startX = (int)(position.X + (size.Width * swipePercentage));
int startX = (int)(position.X + (size.Width * swipePercentage));
int startY = position.Y + size.Height / 2;

int endX = (int)(position.X + (size.Width * 0.05));
Expand All @@ -206,10 +206,10 @@ static void ScrollToRight(AppiumDriver driver, AppiumElement element, ScrollStra

static void ScrollToUp(AppiumDriver driver, AppiumElement element, ScrollStrategy strategy, double swipePercentage, int swipeSpeed, bool withInertia = true)
{
var position = element is not null ? element.Location : System.Drawing.Point.Empty;
var size = element is not null ? element.Size : driver.Manage().Window.Size;
var position = element is not null ? element.Location : System.Drawing.Point.Empty;
var size = element is not null ? element.Size : driver.Manage().Window.Size;

int startX = position.X + size.Width / 2;
int startX = position.X + size.Width / 2;
int startY = (int)(position.Y + (size.Height * 0.05));

int endX = startX;
Expand Down
4 changes: 2 additions & 2 deletions src/TestUtils/src/UITest.Appium/Actions/AppiumSwipeActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CommandResponse SwipeLeftToRight(IDictionary<string, object> parameters)
parameters.TryGetValue("element", out var value);
var element = GetAppiumElement(value);

double swipePercentage = (double)parameters["swipePercentage"];
double swipePercentage = (double)parameters["swipePercentage"];
int swipeSpeed = (int)parameters["swipeSpeed"];
bool withInertia = (bool)parameters["withInertia"];

Expand All @@ -58,7 +58,7 @@ CommandResponse SwipeRightToLeft(IDictionary<string, object> parameters)
parameters.TryGetValue("element", out var value);
var element = GetAppiumElement(value);

double swipePercentage = (double)parameters["swipePercentage"];
double swipePercentage = (double)parameters["swipePercentage"];
int swipeSpeed = (int)parameters["swipeSpeed"];
bool withInertia = (bool)parameters["withInertia"];

Expand Down