Skip to content

Commit 7e7cd24

Browse files
Enabeld 47th set of Migrated test cases from XamarinUITest into Appium (#46) (#26606)
* Migrated the Bugzilla39530 and Issue1614 * Addressed the feedback --------- Co-authored-by: nivetha-nagalingam <nivetha.nagalingam@syncfusion.com>
1 parent 80a7fcf commit 7e7cd24

File tree

3 files changed

+53
-67
lines changed

3 files changed

+53
-67
lines changed

src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla39530.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ protected override void Init()
1414
var tapgr = new TapGestureRecognizer();
1515
var pinchgr = new PinchGestureRecognizer();
1616

17+
var frameLabel = new Label
18+
{
19+
Text = "Frame Content",
20+
AutomationId = "frameLabel",
21+
HorizontalOptions = LayoutOptions.Center,
22+
VerticalOptions = LayoutOptions.Center
23+
};
24+
1725
var frame = new Frame
1826
{
1927
HasShadow = false,
@@ -23,7 +31,8 @@ protected override void Init()
2331
Padding = new Thickness(5),
2432
HeightRequest = 300,
2533
WidthRequest = 300,
26-
AutomationId = "frame"
34+
AutomationId = "frame",
35+
Content = frameLabel
2736
};
2837

2938
var tapCount = 0;
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using System.Drawing;
1+
#if TEST_FAILS_ON_CATALYST //Pan is not working on the MacCatalyst.
2+
using System.Drawing;
23
using NUnit.Framework;
3-
using NUnit.Framework.Legacy;
44
using UITest.Appium;
55
using UITest.Core;
66

@@ -16,45 +16,36 @@ public Bugzilla39530(TestDevice testDevice) : base(testDevice)
1616
public override string Issue => "Frames do not handle pan or pinch gestures under AppCompat";
1717

1818
[Test]
19-
[FailsOnIOSWhenRunningOnXamarinUITest]
20-
[FailsOnMacWhenRunningOnXamarinUITest]
21-
[FailsOnWindowsWhenRunningOnXamarinUITest("Fails finding the frame element. Investigate the cause.")]
2219
public void Bugzilla39530PanTest()
2320
{
24-
if (App is not AppiumApp app2 || app2 is null || app2.Driver is null)
25-
{
26-
throw new InvalidOperationException("Cannot run test. Missing driver to run quick tap actions.");
27-
}
28-
29-
// Got to wait for the element to be visible to the UI test framework, otherwise we get occasional
30-
// index out of bounds exceptions if the query for the frame and its Rect run quickly enough
31-
App.WaitForElement("frame");
32-
Rectangle frameBounds = App.FindElement("frame").GetRect();
21+
App.WaitForElement("frameLabel");
22+
Rectangle frameBounds = App.FindElement("frameLabel").GetRect();
3323
App.Pan(frameBounds.CenterX(), frameBounds.Y + 10, frameBounds.X + 100, frameBounds.Y + 100);
34-
var result = app2.Driver.FindElement(OpenQA.Selenium.By.XPath("//*[@text='" + "Panning: Completed" + "']"));
35-
ClassicAssert.IsNotEmpty(result.Text);
24+
App.WaitForElement("Panning: Completed");
3625
}
3726

38-
/*
27+
3928
[Test]
40-
[FailsOnIOSWhenRunningOnXamarinUITest]
41-
[FailsOnMacWhenRunningOnXamarinUITest]
4229
public void Bugzilla39530PinchTest()
4330
{
31+
//The PinchToZoomIn gesture doesn't work on the Frame for other platforms, so it should be applied to the children of the Frame instead.
32+
#if ANDROID
4433
App.PinchToZoomIn("frame");
45-
App.WaitForElement(q => q.Marked("Pinching: Completed"));
34+
#else
35+
App.PinchToZoomIn("frameLabel");
36+
#endif
37+
App.WaitForElement("Pinching: Completed");
4638
}
4739

4840
[Test]
49-
[FailsOnIOSWhenRunningOnXamarinUITest]
50-
[FailsOnMacWhenRunningOnXamarinUITest]
5141
public void Bugzilla39530TapTest()
5242
{
53-
App.WaitForElement("frame");
54-
App.Tap("frame");
43+
App.WaitForElement("frameLabel");
44+
App.Tap("frameLabel");
5545
App.WaitForElement("Taps: 1");
56-
App.Tap("frame");
46+
App.Tap("frameLabel");
5747
App.WaitForElement("Taps: 2");
5848
}
59-
*/
49+
6050
}
51+
#endif
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if IOS
1+
#if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS //The test fails on Windows and MacCatalyst because the SetOrientation method, which is intended to change the device orientation, is only supported on mobile platforms Android and iOS.
22
using NUnit.Framework;
33
using UITest.Appium;
44
using UITest.Core;
@@ -7,51 +7,37 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;
77

88
public class Issue1614 : _IssuesUITest
99
{
10+
#if ANDROID
11+
const string Done = "Cancel";
12+
#else
13+
const string Done = "Done";
14+
#endif
15+
1016
public Issue1614(TestDevice testDevice) : base(testDevice)
1117
{
1218
}
1319

1420
public override string Issue => "iOS 11 prevents InputAccessoryView from showing in landscape mode";
1521

16-
// [Test]
17-
// [FailsOnIOS]
18-
// public void Issue1614Test()
19-
// {
20-
// App.SetOrientationPortrait();
21-
22-
// App.WaitForElement(x => x.Class("UITextField"));
23-
// App.Tap(x => x.Class("UITextField").Index(0));
24-
// CheckPickerAccessory("UIPickerView");
25-
// App.SetOrientationLandscape();
26-
// CheckPickerAccessory("UIPickerView");
27-
// App.SetOrientationPortrait();
28-
// App.DismissKeyboard();
29-
30-
// App.Tap(x => x.Class("UITextField").Index(1));
31-
// CheckPickerAccessory("UIDatePicker");
32-
// App.SetOrientationLandscape();
33-
// CheckPickerAccessory("UIDatePicker");
34-
// App.SetOrientationPortrait();
35-
// App.DismissKeyboard();
36-
37-
// App.Tap(x => x.Class("UITextField").Index(2));
38-
// CheckPickerAccessory("UIDatePicker");
39-
// App.SetOrientationLandscape();
40-
// CheckPickerAccessory("UIDatePicker");
41-
// App.SetOrientationPortrait();
42-
// App.DismissKeyboard();
43-
// }
44-
45-
// private void CheckPickerAccessory(string className)
46-
// {
47-
// App.WaitForElement(x => x.Class("UIButtonLabel"));
48-
// var buttonRect = App.Query(x => x.Class("UIButtonLabel"))[0].Rect;
49-
// var pickerRect = App.Query(x => x.Class(className))[0].Rect;
50-
51-
// var buttonBottom = buttonRect.Y + buttonRect.Height;
52-
// var pickerTop = pickerRect.Y;
22+
[Test]
23+
[Category(UITestCategories.Picker)]
24+
public void Issue1614Test()
25+
{
26+
TapPicker("Picker");
27+
TapPicker("DatePicker");
28+
TapPicker("TimePicker");
29+
}
5330

54-
// Assert.IsTrue(buttonBottom <= pickerTop);
55-
// }
31+
void TapPicker(string picker)
32+
{
33+
App.WaitForElement(picker);
34+
App.Tap(picker);
35+
App.WaitForElement(Done);
36+
App.SetOrientationLandscape();
37+
App.WaitForElement(Done);
38+
App.SetOrientationPortrait();
39+
App.WaitForElement(Done);
40+
App.Tap(Done);
41+
}
5642
}
5743
#endif

0 commit comments

Comments
 (0)