summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42074.cs
blob: 04bcdf8cdf803562786df67557caa31918078e32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;

using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
    [Preserve(AllMembers = true)]
    [Issue(IssueTracker.Bugzilla, 42074, "[Android] Clicking cancel on a TimePicker does not cause it to unfocus", PlatformAffected.Android)]
    public class Bugzilla42074 : TestContentPage
    {
        const string TimePicker = "TimePicker";

        protected override void Init()
        {
            var timePicker = new TimePicker
            {
                AutomationId = TimePicker
            };
            var timePickerFocusButton = new Button
            {
                Text = "Click to focus TimePicker",
                Command = new Command(() => timePicker.Focus())
            };
            Content = new StackLayout
            {
                Children =
                {
                    timePicker,
                    timePickerFocusButton
                }
            };
        }

#if UITEST

#if __ANDROID__
        [Test]
        public void TimePickerCancelShouldUnfocus()
        {
            RunningApp.Tap(q => q.Marked(TimePicker));
            RunningApp.WaitForElement(q => q.Marked("Cancel"));

            RunningApp.Tap(q => q.Marked("Cancel"));
            RunningApp.WaitForElement(q => q.Marked("Click to focus TimePicker"));

            RunningApp.Tap(q => q.Marked("Click to focus TimePicker"));
            RunningApp.WaitForElement(q => q.Marked("Cancel"));

            RunningApp.Tap(q => q.Marked("Cancel"));
        }
#endif

#endif
    }
}