Handle case where GetRenderer retuns null (#7566) Fixes #7563
authorStuart Lang <stuart.b.lang@gmail.com>
Sun, 29 Sep 2019 21:01:37 +0000 (22:01 +0100)
committerRui Marinho <me@ruimarinho.net>
Sun, 29 Sep 2019 21:01:37 +0000 (22:01 +0100)
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7563.cs [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs

diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7563.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7563.cs
new file mode 100644 (file)
index 0000000..ac86cbe
--- /dev/null
@@ -0,0 +1,36 @@
+using System.Threading;
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.Forms.Core.UITests;
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+#if UITEST
+       [Category(UITestCategories.ManualReview)]
+#endif
+       [Preserve(AllMembers = true)]
+       [Issue(IssueTracker.Github, 7563, "iOS Layout Compression should not crash when VoiceOver is active", PlatformAffected.iOS)]
+       public class Issue7563 : TestContentPage
+       {
+               protected override void Init()
+               {
+
+                       var stack = new StackLayout
+                       {
+                               AutomationId = "test",
+                               Children = { new Label { Text = "Turn on the Screen Reader. If you do not hear 'I am the StackLayout', this test has failed." } },
+                       };
+                       
+                       Xamarin.Forms.CompressedLayout.SetIsHeadless(stack, true);
+                       
+                       AutomationProperties.SetIsInAccessibleTree(stack, true);
+                       AutomationProperties.SetName(stack, "I am the StackLayout. This should be announced.");
+                       Content = stack;
+               }
+       }
+}
\ No newline at end of file
index 369f053..10e942e 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)Issue6929.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Controls\ApiLabel.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue7582.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)Issue7563.cs" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla22229.xaml">
index ea9b1b7..41b3216 100644 (file)
@@ -72,7 +72,7 @@ namespace Xamarin.Forms.Platform.iOS
                                                !(
                                                        child is VisualElement ve && ve.IsTabStop
                                                        && AutomationProperties.GetIsInAccessibleTree(ve) != false // accessible == true
-                                                       && ve.GetRenderer().NativeView is UIView view)
+                                                       && ve.GetRenderer()?.NativeView is UIView view)
                                                 )
                                                continue;