Isolate the TemplatedView check inside Platform.cs to just RadioButton until we can provide a more generalized fix (#13279)

* UI Test

* - Hack fix for now

* - fiix UI Test wording

* - apply to UWP

* - add UI Test for RB Templates

* - fix categories
This commit is contained in:
Shane Neuville 2021-01-04 20:21:18 -06:00 коммит произвёл GitHub
Родитель 3763db8d1b
Коммит cfd463fc4f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 96 добавлений и 17 удалений

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

@ -18,7 +18,19 @@ namespace Xamarin.Forms.ControlGallery.Android
{
base.OnElementChanged(e);
Console.WriteLine("Issue12484 Test passed.");
if(e.NewElement.Children[0] is Issue12484CustomView.Issue12484Template t &&
t.Content is StackLayout g)
{
var label = new Label
{
AutomationId = "Success",
Text = "Success",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
g.Children.Add(label);
}
}
}
}

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

@ -49,17 +49,16 @@ namespace Xamarin.Forms.Controls.Issues
{
public Issue12484Template()
{
var label = new Label
var content = new StackLayout()
{
AutomationId = "Success",
Text = "If this text appear, the test has passed.",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
Children =
{
new Label()
{
Text = "If a label with text `Success` does not show up this test has failed"
}
}
};
var content = new Grid();
content.Children.Add(label);
Content = content;
}
}

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

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Text;
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.RadioButton)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.None, 0, "RadioButton: Template From Style", PlatformAffected.All)]
public class RadioButtonTemplateFromStyle : TestNavigationPage
{
protected override void Init()
{
#if APP
PushAsync(new GalleryPages.RadioButtonGalleries.TemplateFromStyle());
#endif
}
#if UITEST
[Test]
public void ContentRenderers()
{
RunningApp.WaitForElement("A");
RunningApp.WaitForElement("B");
RunningApp.WaitForElement("C");
}
#endif
}
}

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

@ -12,6 +12,7 @@
<Compile Include="$(MSBuildThisFileDirectory)CollectionViewGroupTypeIssue.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11214.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13109.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RadioButtonTemplateFromStyle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ShellWithCustomRendererDisabledAnimations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ShellFlyoutContent.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue4720.cs" />

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

@ -339,11 +339,23 @@ namespace Xamarin.Forms.Platform.Android
internal static IVisualElementRenderer CreateRenderer(VisualElement element, Context context)
{
IVisualElementRenderer renderer = Registrar.Registered.GetHandlerForObject<IVisualElementRenderer>(element, context)
?? new DefaultRenderer(context);
IVisualElementRenderer renderer = null;
// temporary hack to fix the following issues
// https://github.com/xamarin/Xamarin.Forms/issues/13261
// https://github.com/xamarin/Xamarin.Forms/issues/12484
if (element is RadioButton tv && tv.ResolveControlTemplate() != null)
{
renderer = new DefaultRenderer(context);
}
if (renderer == null)
{
renderer = Registrar.Registered.GetHandlerForObject<IVisualElementRenderer>(element, context)
?? new DefaultRenderer(context);
}
renderer.SetElement(element);
return renderer;
}

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

@ -45,7 +45,10 @@ namespace Xamarin.Forms.Platform.UWP
IVisualElementRenderer renderer = null;
if (element is TemplatedView tv && tv.ResolveControlTemplate() != null)
// temporary hack to fix the following issues
// https://github.com/xamarin/Xamarin.Forms/issues/13261
// https://github.com/xamarin/Xamarin.Forms/issues/12484
if (element is RadioButton tv && tv.ResolveControlTemplate() != null)
{
renderer = new DefaultRenderer();
}

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

@ -222,9 +222,21 @@ namespace Xamarin.Forms.Platform.iOS
public static IVisualElementRenderer CreateRenderer(VisualElement element)
{
IVisualElementRenderer renderer = Internals.Registrar.Registered.GetHandlerForObject<IVisualElementRenderer>(element)
?? new DefaultRenderer();
IVisualElementRenderer renderer = null;
// temporary hack to fix the following issues
// https://github.com/xamarin/Xamarin.Forms/issues/13261
// https://github.com/xamarin/Xamarin.Forms/issues/12484
if (element is RadioButton tv && tv.ResolveControlTemplate() != null)
{
renderer = new DefaultRenderer();
}
if (renderer == null)
{
renderer = Internals.Registrar.Registered.GetHandlerForObject<IVisualElementRenderer>(element) ?? new DefaultRenderer();
}
renderer.SetElement(element);
return renderer;