@@ -16,13 +16,18 @@ namespace Xamarin.Forms.Controls.Issues
16
16
#endif
17
17
[ Preserve ( AllMembers = true ) ]
18
18
[ Issue ( IssueTracker . Github , 12497 , "Calling Focus() on a WebView on UWP does not move the focus to the WebView" , PlatformAffected . UWP ) ]
19
- public class Issue12497 : TestContentPage // or TestFlyoutPage, etc ...
19
+ public class Issue12497 : TestContentPage
20
20
{
21
21
bool _firstTimeOnAppearing = true ;
22
22
Button _button1 ;
23
23
Button _button2 ;
24
24
Button _button3 ;
25
25
WebView _webView ;
26
+ Label _label ;
27
+
28
+ const string FAIL = "Fail" ;
29
+ const string SUCCESS = "Success" ;
30
+ const string btnAutomationId = "btn3" ;
26
31
27
32
protected override void Init ( )
28
33
{
@@ -56,6 +61,11 @@ void PopulatePage()
56
61
{
57
62
int defaultTabIndex = Int32 . MaxValue ; // UWP says this should be the max int. Xamarin.Forms docs say it should be 0;
58
63
64
+ _label = new Label
65
+ {
66
+ Text = FAIL
67
+ } ;
68
+
59
69
_button1 = new Button
60
70
{
61
71
Text = "Button 1 (should be first in tab order)" ,
@@ -77,6 +87,11 @@ void PopulatePage()
77
87
}
78
88
} ;
79
89
90
+ _webView . Focused += ( s , e ) =>
91
+ {
92
+ _label . Text = SUCCESS ;
93
+ } ;
94
+
80
95
_button2 = new Button
81
96
{
82
97
Text = "Button 2 (should be third in tab order)" ,
@@ -88,6 +103,7 @@ void PopulatePage()
88
103
89
104
_button3 = new Button
90
105
{
106
+ AutomationId = btnAutomationId ,
91
107
Text = "Button 3 (press to set focus to WebView)" ,
92
108
TextColor = Color . Black ,
93
109
BackgroundColor = Color . White ,
@@ -105,13 +121,23 @@ void PopulatePage()
105
121
VerticalOptions = LayoutOptions . Fill ,
106
122
BackgroundColor = Color . Pink ,
107
123
Children =
108
- {
109
- _button1 ,
110
- _webView ,
111
- _button2 ,
112
- _button3
113
- }
124
+ {
125
+ _button1 ,
126
+ _webView ,
127
+ _button2 ,
128
+ _button3 ,
129
+ _label
130
+ }
114
131
} ;
115
132
}
133
+
134
+ #if UITEST
135
+ [ Test ]
136
+ public void Issue12497Test ( )
137
+ {
138
+ RunningApp . Tap ( btnAutomationId ) ;
139
+ RunningApp . WaitForElement ( SUCCESS ) ;
140
+ }
141
+ #endif
116
142
}
117
143
}
0 commit comments