2019-01-13 01:43:08 +03:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Xamarin.Forms.CustomAttributes;
|
2016-04-26 18:20:55 +03:00
|
|
|
|
using Xamarin.Forms.Internals;
|
2016-03-27 09:29:45 +03:00
|
|
|
|
|
2019-01-13 01:43:08 +03:00
|
|
|
|
#if UITEST
|
|
|
|
|
using Xamarin.Forms.Core.UITests;
|
|
|
|
|
using Xamarin.UITest;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-11-07 01:00:08 +03:00
|
|
|
|
namespace Xamarin.Forms.Controls.Issues
|
2016-03-27 09:29:45 +03:00
|
|
|
|
{
|
2019-01-13 01:43:08 +03:00
|
|
|
|
#if UITEST
|
|
|
|
|
[Category(UITestCategories.Entry)]
|
|
|
|
|
[Category(UITestCategories.Editor)]
|
|
|
|
|
[Category(UITestCategories.Focus)]
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-03-27 09:29:45 +03:00
|
|
|
|
[Preserve(AllMembers = true)]
|
|
|
|
|
[Issue(IssueTracker.Bugzilla, 39702, "Cannot enter text when Entry is focus()'d from an editor completed event")]
|
2019-01-13 01:43:08 +03:00
|
|
|
|
public class Bugzilla39702 : TestContentPage
|
2016-03-27 09:29:45 +03:00
|
|
|
|
{
|
2019-01-13 01:43:08 +03:00
|
|
|
|
const string TheEntry = "TheEntry";
|
|
|
|
|
const string Success = "Success";
|
|
|
|
|
|
|
|
|
|
protected override async void Init()
|
2016-03-27 09:29:45 +03:00
|
|
|
|
{
|
|
|
|
|
Title = "focus test";
|
|
|
|
|
var editor = new Editor();
|
2019-01-13 01:43:08 +03:00
|
|
|
|
var entry = new Entry { AutomationId = TheEntry };
|
|
|
|
|
var result = new Label();
|
|
|
|
|
|
|
|
|
|
var instructions = new Label
|
|
|
|
|
{
|
|
|
|
|
Text = "Wait 4 seconds; the Entry (third control from the top) should be focused, and the keyboard"
|
|
|
|
|
+ " should be visible. Typing on the keyboard should enter text into the Entry."
|
|
|
|
|
+ " If the typing does not enter text into the Entry, this test has failed."
|
|
|
|
|
};
|
2016-03-27 09:29:45 +03:00
|
|
|
|
|
2019-01-13 01:43:08 +03:00
|
|
|
|
editor.Unfocused += (sender, e) => entry.Focus();
|
|
|
|
|
entry.TextChanged += (sender, args) => result.Text = args.NewTextValue;
|
2016-03-27 09:29:45 +03:00
|
|
|
|
|
|
|
|
|
Content = new StackLayout
|
|
|
|
|
{
|
|
|
|
|
Children =
|
|
|
|
|
{
|
2019-01-13 01:43:08 +03:00
|
|
|
|
instructions,
|
2016-03-27 09:29:45 +03:00
|
|
|
|
editor,
|
2019-01-13 01:43:08 +03:00
|
|
|
|
entry,
|
|
|
|
|
result
|
2016-03-27 09:29:45 +03:00
|
|
|
|
}
|
|
|
|
|
};
|
2019-01-13 01:43:08 +03:00
|
|
|
|
|
|
|
|
|
await Task.Delay(2000);
|
|
|
|
|
editor.Focus();
|
|
|
|
|
await Task.Delay(1000);
|
|
|
|
|
editor.Unfocus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if UITEST
|
|
|
|
|
[Test]
|
|
|
|
|
public async void ControlCanBeFocusedByUnfocusedEvent()
|
|
|
|
|
{
|
|
|
|
|
RunningApp.WaitForElement(TheEntry);
|
|
|
|
|
await Task.Delay(4000);
|
|
|
|
|
RunningApp.EnterText(Success); // Should be typing into the Entry at this point
|
|
|
|
|
RunningApp.WaitForElement(Success);
|
2016-03-27 09:29:45 +03:00
|
|
|
|
}
|
2019-01-13 01:43:08 +03:00
|
|
|
|
#endif
|
2016-03-27 09:29:45 +03:00
|
|
|
|
}
|
2018-11-07 01:00:08 +03:00
|
|
|
|
}
|