Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Testing] Enabling ported UITests from Xamarin.UITests to Appium - 30 #26367

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Maui.Controls.Sample.Issues;


[Issue(IssueTracker.Github, 3475, "[iOS] LayoutCompression Performance Issues", PlatformAffected.iOS)]
public class Issue3475 : TestContentPage
public class Issue3475 : TestNavigationPage
{
string _withoutCompressionBtnId = "button1";
string _withCompressionBtnId = "button2";
Expand Down Expand Up @@ -32,7 +32,7 @@ protected override void Init()
AutomationId = _withCompressionBtnId
};

Content = new StackLayout
var content = new StackLayout
{
Padding = 10,
Children =
Expand All @@ -46,6 +46,8 @@ protected override void Init()
withCompressionBtn
}
};

Navigation.PushAsync(new ContentPage { Content = content });
}

public int GetMs(string text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ protected override void Init()

editor = new Editor();
entry = new Entry();

editor.SetBinding(Editor.TextProperty, "Text");
// On iOS, the app freezes. Changing the binding mode to one-way resolves the issue. It seems an infinite loop occurs when properties bind to each other.
editor.SetBinding(Editor.TextProperty, "Text", mode: BindingMode.OneWay);
editor.BindingContext = entry;
editor.Placeholder = "Editor";
editor.AutoSize = EditorAutoSizeOption.TextChanges;
Expand All @@ -36,10 +36,6 @@ protected override void Init()
protected override void OnAppearing()
{
base.OnAppearing();
#pragma warning disable CS0618 // Type or member is obsolete
#pragma warning disable CS0612 // Type or member is obsolete
Device.BeginInvokeOnMainThread(GarbageCollectionHelper.Collect);
#pragma warning restore CS0612 // Type or member is obsolete
#pragma warning restore CS0618 // Type or member is obsolete
MainThread.BeginInvokeOnMainThread(GarbageCollectionHelper.Collect);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,50 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue3475 : _IssuesUITest
{
const string _withoutCompressionBtnId = "button1";
const string _withCompressionBtnId = "button2";
const string _titleLabelId = "Label1";
const int ItemsCount = 150;
const string ElapsedLabelId = "elapsed";
const string DoneLabelId = "done";

public Issue3475(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "[iOS] LayoutCompression Performance Issues";

// [Test]
// [Category(UITestCategories.Layout)]
// [FailsOnAndroid]
// [FailsOnIOS]
// public void Issue3475TestsLayoutCompressionPerformance()
// {
// App.WaitForElement(_titleLabelId);
// App.WaitForElement(_withoutCompressionBtnId);
// App.WaitForElement(_withCompressionBtnId);
[Test]
[Category(UITestCategories.Layout)]
public void Issue3475TestsLayoutCompressionPerformance()
{
App.WaitForElement(_titleLabelId);
App.WaitForElement(_withoutCompressionBtnId);
App.WaitForElement(_withCompressionBtnId);

// App.Tap(_withoutCompressionBtnId);
// App.WaitForElement(DoneLabelId);
// App.Screenshot("Without Layout Compression");
App.Tap(_withoutCompressionBtnId);
App.WaitForElement(DoneLabelId);

// int elapsedWithoutCompression = GetMs(App.Query(ElapsedLabelId).First().Text);
int elapsedWithoutCompression = GetMs(App.WaitForElement(ElapsedLabelId).GetText()!);

// App.Tap(BackButtonId);
// App.WaitForElement(_withCompressionBtnId);
App.TapBackArrow();
App.WaitForElement(_withCompressionBtnId);

// App.Tap(_withCompressionBtnId);
// App.WaitForElement(DoneLabelId);
// App.Screenshot("With Layout Compression");
App.Tap(_withCompressionBtnId);
App.WaitForElement(DoneLabelId);

// int elapsedWithCompression = GetMs(App.Query(ElapsedLabelId).First().Text);
// var delta = elapsedWithCompression - elapsedWithoutCompression;
int elapsedWithCompression = GetMs(App.WaitForElement(ElapsedLabelId).GetText()!);
var delta = elapsedWithCompression - elapsedWithoutCompression;

// //if layoutcompressions is slower than 100 then there is a problem.
// //it should be at least very similar and no more than 100ms slower i guess...
// Assert.LessOrEqual(delta, 100);
// }
//if layoutcompressions is slower than 100 then there is a problem.
//it should be at least very similar and no more than 100ms slower i guess...
Assert.That(delta, Is.LessThanOrEqualTo(100));
}

public int GetMs(string text)
{
text = text.Replace($"Showing {ItemsCount} items took: ", "", StringComparison.OrdinalIgnoreCase).Replace(" ms", "", StringComparison.OrdinalIgnoreCase);
return int.TryParse(text, out int elapsed) ? elapsed : 0;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using NUnit.Framework;
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST // In Windows, getting object null reference exception while running the sample, Issue: /~https://github.com/dotnet/maui/issues/26345
//In MacCatalyst, Timeout Exception in the label line no 20. tried by using App.QueryUntilPresent, and adding delay also won't work.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -11,13 +13,13 @@ public Issue3788(TestDevice testDevice) : base(testDevice)

public override string Issue => "[UWP] ListView with observable collection always seems to refresh the entire list";

// TODO: these _ variables are variabled in the UI and need to be AutomationId values
//[Test]
//[FailsOnIOSWhenRunningOnXamarinUITest]
//public void ReplaceItemScrollsListToTop()
//{
// App.WaitForElement(_replaceMe);
// App.Tap(_buttonText);
// App.WaitForElement(_last);
//}
}
[Test]
[Category(UITestCategories.ListView)]
public void ReplaceItemScrollsListToTop()
{
App.WaitForElement("Replace Me");
App.Tap("Scroll down and click me");
App.WaitForElement("Last");
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_WINDOWS // Test ignored on Windows due to rendering issues. The documentation specifies that TabbedPage should contain NavigationPage or ContentPage, but this sample uses nested TabbedPages. Getting System.InvalidOperationException: 'Collection was modified; enumeration operation may not execute.' exception.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -12,13 +13,14 @@ public Issue4303(TestDevice testDevice) : base(testDevice)

public override string Issue => "[Android] TabbedPage's child is appearing before it should be";

//[Test]
//[Category(UITestCategories.LifeCycle)]
//public void Issue4303Test()
//{
// App.WaitForElement(c => c.Text(Success));
// App.WaitForElement(c => c.Marked(btnAutomationID));
// App.Tap(c => c.Marked(btnAutomationID));
// App.WaitForElement(c => c.Text(ChildSuccess));
//}
}
[Test]
[Category(UITestCategories.LifeCycle)]
public void Issue4303Test()
{
Assert.That(App.WaitForElement("lblAssert").GetText(), Is.EqualTo("Success"));
App.WaitForElement("Go to Tab4");
App.Tap("Go to Tab4");
Assert.That(App.WaitForElement("lblChildAssert").GetText(), Is.EqualTo("ChildSuccess"));
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_ANDROID // Test ignored on Windows and Android due to rendering issues. The documentation specifies that TabbedPage should contain NavigationPage or ContentPage, but this sample uses nested TabbedPages.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -12,19 +13,16 @@ public Issue4973(TestDevice testDevice) : base(testDevice)

public override string Issue => "TabbedPage nav tests";

//[Test]
//[Category(UITestCategories.Navigation)]
//[FailsOnAndroidWhenRunningOnXamarinUITest]
//public void Issue4973Test()
//{
// App.Tap(q => q.Text("Tab5"));

// App.WaitForElement(q => q.Text("Test"));

// GarbageCollectionHelper.Collect();

// App.Tap(q => q.Text("Tab1"));

// App.Tap(q => q.Text("Tab2"));
//}
}
[Test]
[Category(UITestCategories.Navigation)]
public void Issue4973Test()
{
App.WaitForElement("Tab5");
App.Tap("Tab5");
App.WaitForElement("Test");
GC.Collect();
App.Tap("Tab1");
App.Tap("Tab2");
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ public Issue5500(TestDevice testDevice) : base(testDevice)

public override string Issue => "[iOS] Editor with material visuals value binding not working on physical device";

//[Test]
//[Category(UITestCategories.Editor)]
//[FailsOnIOS]
//public void VerifyEditorTextChangeEventsAreFiring()
//{
// App.WaitForElement("EditorAutomationId");
// App.EnterText("EditorAutomationId", "Test 1");

// Assert.AreEqual("Test 1", App.WaitForElement("EditorAutomationId")[0].ReadText());
// Assert.AreEqual("Test 1", App.WaitForElement("EntryAutomationId")[0].ReadText());
[Test]
[Category(UITestCategories.Editor)]
public void VerifyEditorTextChangeEventsAreFiring()
{
App.WaitForElement("EditorAutomationId");
App.EnterText("EditorAutomationId", "Test 1");

// App.ClearText("EntryAutomationId");
// App.EnterText("EntryAutomationId", "Test 2");
var editorText = App.WaitForElement("EditorAutomationId").ReadText();
var entryText = App.WaitForElement("EntryAutomationId").ReadText();
Assert.That(editorText, Is.EqualTo(entryText));

App.ClearText("EntryAutomationId");
App.EnterText("EntryAutomationId", "Test 2");

// Assert.AreEqual("Test 2", App.WaitForElement("EditorAutomationId")[0].ReadText());
// Assert.AreEqual("Test 2", App.WaitForElement("EntryAutomationId")[0].ReadText());
//}
editorText = App.WaitForElement("EditorAutomationId").ReadText();
entryText = App.WaitForElement("EntryAutomationId").ReadText();
Assert.That(editorText, Is.EqualTo(entryText));
}
}
Loading