[iOS] Fix NRE when child wasn't added yet to NavigationPage (#3162)

* [Controls] Add test 15 and rename issues 1583_1

* [iOS] Do not try to layout if no child was added yet

* Update NavigationRenderer.cs
This commit is contained in:
Rui Marinho 2018-06-27 22:33:12 +01:00 коммит произвёл GitHub
Родитель 9fe5372c1d
Коммит 508686bbbe
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 23 добавлений и 10 удалений

Просмотреть файл

@ -3,19 +3,32 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Controls
#if UITEST
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve (AllMembers=true)]
[Issue (IssueTracker.Github, 1583, "NavigationPage.TitleIcon broken", PlatformAffected.Android | PlatformAffected.iOS | PlatformAffected.WinPhone)]
public class Issue1583 : ContentPage
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1583, "NavigationPage.TitleIcon broken", PlatformAffected.Android | PlatformAffected.iOS | PlatformAffected.WinPhone)]
public class Issue1583 : TestContentPage
{
public Issue1583 ()
protected override void Init()
{
Title = "Test";
BackgroundColor = Color.Pink;
Content = new Label{Text = "Hello"};
Content = new Label { Text = "Hello", AutomationId ="lblHello" };
NavigationPage.SetTitleIcon(this, "bank.png");
}
#if UITEST
[Test]
public void Issue1583TitleIconTest ()
{
RunningApp.WaitForElement(q => q.Marked ("lblHello"));
}
#endif
}
}

Просмотреть файл

@ -11,7 +11,7 @@ namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1583, "WebView fails to load from urlwebviewsource with non-ascii characters (works with Uri)", PlatformAffected.iOS, issueTestNumber: 1)]
public class Issue1583 : TestContentPage
public class Issue1583_1 : TestContentPage
{
WebView _webview;
Label _label;
@ -63,7 +63,7 @@ namespace Xamarin.Forms.Controls.Issues
#if UITEST
[Test]
public async Task Issue1583Test ()
public async Task Issue1583_1_WebviewTest ()
{
RunningApp.WaitForElement (q => q.Marked ("label"), "Could not find label", TimeSpan.FromSeconds(10), null, null);
await Task.Delay(TimeSpan.FromSeconds(3));

Просмотреть файл

@ -1341,7 +1341,7 @@ namespace Xamarin.Forms.Platform.iOS
if (_icon != null)
_icon.Frame = new RectangleF(0, 0, IconWidth, Math.Min(toolbarHeight, IconHeight));
if (_child.Element != null)
if (_child?.Element != null)
Layout.LayoutChildIntoBoundingRegion(_child.Element, new Rectangle(IconWidth, 0, Bounds.Width - IconWidth, height));
}
@ -1359,4 +1359,4 @@ namespace Xamarin.Forms.Platform.iOS
}
}
}
}
}