This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trigger pop logic when you replace back button with icon (#12320)
* Trigger pop logic when you replace back button with icon * - fix nested pages not updating tab visibility correctly * - fix ui tests * - fix ui test * - fix uitest * - fix ui test
- Loading branch information
Showing
6 changed files
with
170 additions
and
22 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12126.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,79 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Text; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
|
||
|
||
#if UITEST | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
using Xamarin.Forms.Core.UITests; | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 12126, "[iOS] TabBarIsVisible = True/False breaking for multiple nested pages", | ||
PlatformAffected.iOS)] | ||
#if UITEST | ||
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github10000)] | ||
[NUnit.Framework.Category(UITestCategories.Shell)] | ||
#endif | ||
public class Issue12126 : TestShell | ||
{ | ||
bool firstNavigated = true; | ||
protected override void Init() | ||
{ | ||
var page1 = AddFlyoutItem("Tab 1"); | ||
AddBottomTab("Tab 2"); | ||
Shell.SetTabBarIsVisible(page1, true); | ||
} | ||
|
||
protected override async void OnNavigated(ShellNavigatedEventArgs args) | ||
{ | ||
base.OnNavigated(args); | ||
|
||
if(firstNavigated) | ||
{ | ||
firstNavigated = false; | ||
ContentPage contentPage = new ContentPage(); | ||
contentPage.Content = new Label() | ||
{ | ||
Text = "If you don't see any bottom tabs the test has failed" | ||
}; | ||
Shell.SetTabBarIsVisible(contentPage, true); | ||
|
||
ContentPage contentPage2 = new ContentPage(); | ||
contentPage2.Content = | ||
new StackLayout() | ||
{ | ||
Children = | ||
{ | ||
new Label() | ||
{ | ||
Text = "Click The Back Arrow", | ||
AutomationId = "TestReady" | ||
} | ||
} | ||
}; | ||
|
||
Shell.SetTabBarIsVisible(contentPage2, false); | ||
await Navigation.PushAsync(contentPage); | ||
await Navigation.PushAsync(contentPage2); | ||
} | ||
} | ||
|
||
|
||
#if UITEST && __SHELL__ | ||
[Test] | ||
public void NavigatingBackFromMultiplePushPagesChangesTabVisibilityCorrectly() | ||
{ | ||
RunningApp.WaitForElement("TestReady"); | ||
TapBackArrow(); | ||
RunningApp.WaitForElement("Tab 1"); | ||
} | ||
#endif | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12320.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,71 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Text; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
|
||
|
||
#if UITEST | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
using Xamarin.Forms.Core.UITests; | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 12320, "[iOS] TabBarIsVisible = True/False doesn't work on Back Navigation When using BackButtonBehavior", | ||
PlatformAffected.iOS)] | ||
#if UITEST | ||
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github10000)] | ||
[NUnit.Framework.Category(UITestCategories.Shell)] | ||
#endif | ||
public class Issue12320 : TestShell | ||
{ | ||
bool firstNavigated = true; | ||
protected override void Init() | ||
{ | ||
var page1 = new ContentPage(); | ||
page1.Content = new Label() | ||
{ | ||
Text = "If you don't see any bottom tabs the test has failed" | ||
}; | ||
|
||
AddFlyoutItem(page1, "Tab 1"); | ||
AddBottomTab("Tab 2"); | ||
Shell.SetTabBarIsVisible(page1, true); | ||
} | ||
|
||
protected override async void OnNavigated(ShellNavigatedEventArgs args) | ||
{ | ||
base.OnNavigated(args); | ||
|
||
if(firstNavigated) | ||
{ | ||
firstNavigated = false; | ||
ContentPage contentPage = new ContentPage(); | ||
contentPage.Content = new Label() | ||
{ | ||
Text = "Click the Coffee Cup in the Nav Bar", | ||
AutomationId = "TestReady" | ||
}; | ||
|
||
Shell.SetTabBarIsVisible(contentPage, false); | ||
Shell.SetBackButtonBehavior(contentPage, new BackButtonBehavior() { IconOverride = "coffee.png" }); | ||
await Navigation.PushAsync(contentPage); | ||
} | ||
} | ||
|
||
|
||
#if UITEST && __SHELL__ | ||
[Test] | ||
public void PopLogicExecutesWhenUsingBackButtonBehavior() | ||
{ | ||
RunningApp.WaitForElement("TestReady"); | ||
base.TapBackArrow(); | ||
RunningApp.WaitForElement("Tab 1"); | ||
} | ||
#endif | ||
} | ||
} |
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