Skip to content

Commit

Permalink
[Testing] Reenable test ported from Xamarin.UITest (#25624)
Browse files Browse the repository at this point in the history
* Reenable test ported from Xamarin.UITest

* Added Category

* Updated test

* More changes
  • Loading branch information
jsuarezruiz authored Nov 6, 2024
1 parent 6a65d5e commit e720f1e
Showing 1 changed file with 48 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,67 +1,71 @@
using NUnit.Framework;
#if TEST_FAILS_ON_WINDOWS
using NUnit.Framework;
using NUnit.Framework.Legacy;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue3809 : _IssuesUITest
{
const string SetPagePadding = "Set Page Padding";
const string SafeAreaText = "Safe Area Enabled: ";
const string PaddingLabel = "paddingLabel";
const string SafeAreaAutomationId = "SafeAreaAutomation";

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

public override string Issue => "SetUseSafeArea is wiping out Page Padding ";

// TODO: The _ variables need to be AutomationId values
//void AssertSafeAreaText(string text)
//{
// var element =
// RunningApp
// .WaitForFirstElement(_safeAreaAutomationId);

// element.AssertHasText(text);
//}

//[Test]
//[Category(UITestCategories.Layout)]
//public void SafeAreaInsetsBreaksAndroidPadding()
//{
// // ensure initial paddings are honored
// AssertSafeAreaText($"{_safeAreaText}{true}");
// var element = App.WaitForFirstElement(_paddingLabel);
void AssertSafeAreaText(string text)
{
var element = App.WaitForFirstElement(SafeAreaAutomationId);

// bool usesSafeAreaInsets = false;
// if (element.ReadText() != "25, 25, 25, 25")
// usesSafeAreaInsets = true;
ClassicAssert.AreEqual(element.GetText(), text);
}

// Assert.AreNotEqual(element.ReadText(), "0, 0, 0, 0");
// if (!usesSafeAreaInsets)
// Assert.AreEqual(element.ReadText(), "25, 25, 25, 25");
[Test]
[Category(UITestCategories.Layout)]
[Category(UITestCategories.Page)]
public void SafeAreaInsetsBreaksAndroidPadding()
{
// Ensure initial paddings are honored
AssertSafeAreaText($"{SafeAreaText}{true}");
var element = App.WaitForFirstElement(PaddingLabel);

// // disable Safe Area Insets
// App.Tap(_safeAreaAutomationId);
// AssertSafeAreaText($"{_safeAreaText}{false}");
// element = App.WaitForFirstElement(_paddingLabel);
bool usesSafeAreaInsets = false;
if (element.ReadText() != "25, 25, 25, 25")
usesSafeAreaInsets = true;

// Assert.AreEqual(element.ReadText(), "25, 25, 25, 25");
ClassicAssert.AreNotEqual(element.ReadText(), "0, 0, 0, 0");
if (!usesSafeAreaInsets)
ClassicAssert.AreEqual(element.ReadText(), "25, 25, 25, 25");

// // enable Safe Area insets
// App.Tap(_safeAreaAutomationId);
// AssertSafeAreaText($"{_safeAreaText}{true}");
// element = App.WaitForFirstElement(_paddingLabel);
// Assert.AreNotEqual(element.ReadText(), "0, 0, 0, 0");
// Disable Safe Area Insets
App.Tap(SafeAreaAutomationId);
AssertSafeAreaText($"{SafeAreaText}{false}");
element = App.WaitForFirstElement(PaddingLabel);

// if (!usesSafeAreaInsets)
// Assert.AreEqual(element.ReadText(), "25, 25, 25, 25");
ClassicAssert.AreEqual(element.ReadText(), "25, 25, 25, 25");

// Enable Safe Area insets
App.Tap(SafeAreaAutomationId);
AssertSafeAreaText($"{SafeAreaText}{true}");
element = App.WaitForFirstElement(PaddingLabel);
ClassicAssert.AreNotEqual(element.ReadText(), "0, 0, 0, 0");

// // Set Padding and then disable safe area insets
// App.Tap(_setPagePadding);
// App.Tap(_safeAreaAutomationId);
// AssertSafeAreaText($"{_safeAreaText}{false}");
// element = App.WaitForFirstElement(_paddingLabel);
// Assert.AreEqual(element.ReadText(), "25, 25, 25, 25");
if (!usesSafeAreaInsets)
ClassicAssert.AreEqual(element.ReadText(), "25, 25, 25, 25");

//}
// Set Padding and then disable safe area insets
App.Tap(SetPagePadding);
App.Tap(SafeAreaAutomationId);
AssertSafeAreaText($"{SafeAreaText}{false}");
element = App.WaitForFirstElement(PaddingLabel);
ClassicAssert.AreEqual(element.ReadText(), "25, 25, 25, 25");
}
}
}
}
#endif

0 comments on commit e720f1e

Please sign in to comment.