-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Bugzilla41424.cs
108 lines (95 loc) · 2.89 KB
/
Bugzilla41424.cs
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System.Threading;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Bugzilla)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 41424, "[Android] Clicking cancel on a DatePicker does not cause it to unfocus", PlatformAffected.Android)]
public class Bugzilla41424 : TestContentPage
{
const string DatePicker = "DatePicker";
protected override void Init()
{
var stepsTitleLabel = new Label() { Text = "Test steps:" };
var step1Label = new Label() { Text = "• Click 'Click to focus DatePicker'" };
var step2Label = new Label() { Text = "• Click 'Cancel' or back button" };
var step3Label = new Label() { Text = "• Click 'Click to focus DatePicker'" };
var step4Label = new Label() { Text = "• Check that date selector appears" };
var datePickerFocusStateLabel = new Label();
var datePicker = new DatePicker
{
AutomationId = DatePicker
};
datePicker.Focused += (sender, args) => { datePickerFocusStateLabel.Text = "focused"; };
var datePickerFocusButton = new Button
{
Text = "Click to focus DatePicker",
Command = new Command(() => datePicker.Focus())
};
var getDatePickerFocusStateButton = new Button
{
Text = "Click to view focus state",
Command = new Command(() =>
{
datePickerFocusStateLabel.Text = datePicker.IsFocused ? "focused" : "unfocused";
})
};
Content = new StackLayout
{
Children =
{
stepsTitleLabel,
step1Label,
step2Label,
step3Label,
step4Label,
datePicker,
datePickerFocusButton,
getDatePickerFocusStateButton,
datePickerFocusStateLabel
}
};
}
#if UITEST
#if __ANDROID__
[Test]
public void DatePickerCancelShouldUnfocus()
{
RunningApp.Tap(q => q.Marked(DatePicker));
Assert.IsTrue(DialogIsOpened(),"Tap Picker");
RunningApp.WaitForElement(q => q.Marked("Click to view focus state"));
RunningApp.Tap(q => q.Marked("Click to view focus state"));
RunningApp.WaitForElement(q => q.Marked("unfocused"));
RunningApp.Tap(q => q.Marked("Click to focus DatePicker"));
Assert.IsTrue(DialogIsOpened(),"Call Focus Picker");
RunningApp.WaitForElement(q => q.Marked("Click to view focus state"));
RunningApp.Tap(q => q.Marked("Click to view focus state"));
RunningApp.WaitForElement(q => q.Marked("unfocused"));
}
bool DialogIsOpened()
{
Thread.Sleep(1500);
var frameLayouts = RunningApp.Query(q => q.Class("FrameLayout"));
foreach (var layout in frameLayouts)
{
if (layout.Rect.X > 0 && layout.Rect.Y > 0 && layout.Description.Contains(@"id/content"))
{
// close dialog
RunningApp.Back();
Thread.Sleep(1500);
return true;
}
}
return false;
}
#endif
#endif
}
}