diff --git a/src/Controls/tests/TestCases.HostApp/FeatureMatrix/FlyoutPage/FlyoutControlPage.xaml.cs b/src/Controls/tests/TestCases.HostApp/FeatureMatrix/FlyoutPage/FlyoutControlPage.xaml.cs index c7ac995c9b00..8b0987958df2 100644 --- a/src/Controls/tests/TestCases.HostApp/FeatureMatrix/FlyoutPage/FlyoutControlPage.xaml.cs +++ b/src/Controls/tests/TestCases.HostApp/FeatureMatrix/FlyoutPage/FlyoutControlPage.xaml.cs @@ -240,22 +240,34 @@ private async void OnSetDetail2Clicked(object sender, EventArgs e) { if (this.Detail is NavigationPage navPage) { - var detailPage = new ContentPage + var detailLayout = new VerticalStackLayout { - Title = "Detail 2", - Content = new VerticalStackLayout + Children = { - Children = - { - new Label { Text = "Detail 2 - Content" }, - new Button { - Text = "Back to Original Page", - AutomationId = "BackToOriginalDetailButton2", - Command = new Command(async () => await navPage.PopAsync()) - } - } + new Label { Text = "Detail 2 - Content" }, + new Button { + Text = "Back to Original Page", + AutomationId = "BackToOriginalDetailButton2", + Command = new Command(async () => await navPage.PopAsync()) + } } }; + if (_viewModel.ShouldHandleBackButton) + { + var handledLabel = new Label + { + AutomationId = "Detail2BackButtonHandledLabel", + BindingContext = _viewModel + }; + handledLabel.SetBinding(Label.TextProperty, nameof(FlyoutPageViewModel.BackButtonHandled)); + detailLayout.Children.Add(handledLabel); + } + + var detailPage = new ContentPage + { + Title = "Detail 2", + Content = detailLayout + }; detailPage.NavigatedTo += OnPageNavigatedTo; detailPage.NavigatingFrom += OnPageNavigatingFrom; detailPage.NavigatedFrom += OnPageNavigatedFrom; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/FlyoutPageFeatureTests.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/FlyoutPageFeatureTests.cs index 4855b7263f36..93933078b2bc 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/FlyoutPageFeatureTests.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/FlyoutPageFeatureTests.cs @@ -502,15 +502,16 @@ public void Flyout_BackButtonPressed_Handled_True_Should_Stop_Navigation() App.WaitForElement("SetDetail2Button"); App.Tap("SetDetail2Button"); + App.WaitForElement("BackToOriginalDetailButton2"); + Assert.That(App.FindElement("Detail2BackButtonHandledLabel")?.GetText(), Is.EqualTo("False")); App.TapBackArrow(); // If handled → STILL on new page - App.WaitForElement("BackToOriginalDetailButton2"); - App.Tap("BackToOriginalDetailButton2"); - - Assert.That(App.FindElement("BackButtonHandledLabel").GetText(), Is.EqualTo("True")); + Assert.That(App.FindElement("BackToOriginalDetailButton2")?.IsDisplayed(), Is.True); + Assert.That(App.FindElement("Detail2BackButtonHandledLabel")?.GetText(), Is.EqualTo("True")); + App.Tap("BackToOriginalDetailButton2"); } #endif