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

feat: creating Ui test for passwordbox #1081

Merged
merged 15 commits into from
Feb 12, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
smtx:XamlDisplayExtensions.IgnorePath="XamlDisplay\StackPanel">
<StackPanel Spacing="20">

<PasswordBox PlaceholderText="Enter password" />
<PasswordBox PlaceholderText="Enter password" Header="Header" />
<PasswordBox PlaceholderText="Enter password"
AutomationProperties.AutomationId="PasswordBox_NoHeader"/>
<PasswordBox PlaceholderText="Enter password" Header="Header"
AutomationProperties.AutomationId="PasswordBox_Header" />
<PasswordBox PlaceholderText="Disabled"
Header="Header"
IsEnabled="False" />
IsEnabled="False"
AutomationProperties.AutomationId="PasswordBox_Disabled"/>

</StackPanel>
</smtx:XamlDisplay>
Expand All @@ -36,10 +39,13 @@
smtx:XamlDisplayExtensions.IgnorePath="XamlDisplay\StackPanel">
<StackPanel Spacing="20">

<PasswordBox PlaceholderText="Filled" Style="{StaticResource FilledPasswordBoxStyle}" />
<PasswordBox PlaceholderText="Filled" Style="{StaticResource FilledPasswordBoxStyle}"
AutomationProperties.AutomationId="PasswordBox_Default"/>

<PasswordBox PlaceholderText="Disabled"
Style="{StaticResource FilledPasswordBoxStyle}"
IsEnabled="False" />
IsEnabled="False"
AutomationProperties.AutomationId="PasswordBox_Default_Disabled"/>

</StackPanel>
</smtx:XamlDisplay>
Expand All @@ -50,11 +56,13 @@

<PasswordBox PlaceholderText="Outlined"
Header="Header"
Style="{StaticResource OutlinedPasswordBoxStyle}" />
Style="{StaticResource OutlinedPasswordBoxStyle}"
AutomationProperties.AutomationId="PasswordBox_Outlined"/>

<PasswordBox PlaceholderText="Disabled"
Header="Disabled"
Style="{StaticResource OutlinedPasswordBoxStyle}"
AutomationProperties.AutomationId="PasswordBox_Outlined_Disabled"
IsEnabled="False" />

</StackPanel>
Expand All @@ -70,9 +78,11 @@
smtx:XamlDisplayExtensions.IgnorePath="XamlDisplay\StackPanel">
<StackPanel Spacing="20">

<PasswordBox PlaceholderText="Default" Style="{StaticResource CupertinoPasswordBoxStyle}" />
<PasswordBox PlaceholderText="Default" Style="{StaticResource CupertinoPasswordBoxStyle}"
AutomationProperties.AutomationId="PasswordBox_Cupertino"/>
<PasswordBox PlaceholderText="Disabled"
IsEnabled="False"
AutomationProperties.AutomationId="PasswordBox_Cupertino_Disabled"
Style="{StaticResource CupertinoPasswordBoxStyle}" />

</StackPanel>
Expand Down
51 changes: 51 additions & 0 deletions Uno.Gallery/Uno.Gallery.UITest/Given_PasswordBox_Cupertino.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using Uno.UITest.Helpers.Queries;
using Uno.UITests.Helpers;

namespace Uno.Gallery.UITests
{
//[Ignore("WIP: M3 Migration")]
Darsh0307 marked this conversation as resolved.
Show resolved Hide resolved
public class Given_PasswordBox_Cupertino : TestBase
{

[Test]
public void WhenPasswordBoxEnabled()
{
NavigateToSample("PasswordBox", "Cupertino");

TakeScreenshot("Before PasswordBox");

var passwordBoxCupertino = new QueryEx(x => x.All().Marked("PasswordBox_Cupertino"));
App.ScrollDownTo(passwordBoxCupertino);
passwordBoxCupertino.EnterText("Uno platform");

TakeScreenshot("After PasswordBox");
Assert.AreEqual("Uno platform", passwordBoxCupertino.GetDependencyPropertyValue<string>("Password"));

}

[Test]
public void WhenPasswordBoxDisabled()
{
NavigateToSample("PasswordBox", "Cupertino");

TakeScreenshot("Before PasswordBox");

var passwordBox_Disbaled = new QueryEx(x => x.All().Marked("PasswordBox_Cupertino_Disabled"));
App.ScrollDownTo(passwordBox_Disbaled);
passwordBox_Disbaled.EnterText("Uno platform");


TakeScreenshot("After PasswordBox");
Assert.AreEqual("", passwordBox_Disbaled.GetDependencyPropertyValue<string>("Password"));

}


}
}
69 changes: 69 additions & 0 deletions Uno.Gallery/Uno.Gallery.UITest/Given_PasswordBox_Fluent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using Uno.UITest.Helpers.Queries;
using Uno.UITests.Helpers;

namespace Uno.Gallery.UITests
{
//[Ignore("WIP: M3 Migration")]
Darsh0307 marked this conversation as resolved.
Show resolved Hide resolved
public class Given_PasswordBox_Fluent : TestBase
{

[Test]
public void WhenPasswordBoxNoHeader()
{
NavigateToSample("PasswordBox", "Fluent");

TakeScreenshot("Before PasswordBox");

var NoPasswordBox = new QueryEx(x => x.All().Marked("PasswordBox_NoHeader"));
App.ScrollDownTo(NoPasswordBox);
NoPasswordBox.EnterText("Uno platform");

TakeScreenshot("After PasswordBox");
//Assert.IsTrue(NoPasswordBox.GetDependencyPropertyValue<string>("Password") == "Uno platform");
Darsh0307 marked this conversation as resolved.
Show resolved Hide resolved
Assert.AreEqual("Uno platform", NoPasswordBox.GetDependencyPropertyValue<string>("Password"));

}

[Test]
public void WhenPasswordBoxHeader()
{
NavigateToSample("PasswordBox", "Fluent");

TakeScreenshot("Before PasswordBox");

var PasswordBoxHeader = new QueryEx(x => x.All().Marked("PasswordBox_Header"));
App.ScrollDownTo(PasswordBoxHeader);
PasswordBoxHeader.EnterText("Uno platform");

TakeScreenshot("After PasswordBox");
//Assert.IsTrue(NoPasswordBox.GetDependencyPropertyValue<string>("Password") == "Uno platform");
Darsh0307 marked this conversation as resolved.
Show resolved Hide resolved
Assert.AreEqual("Uno platform", PasswordBoxHeader.GetDependencyPropertyValue<string>("Password"));

}

[Test]
public void WhenPasswordBoxHeaderDisabled()
{
NavigateToSample("PasswordBox", "Fluent");

TakeScreenshot("Before PasswordBox");

var PasswordBoxDisabled = new QueryEx(x => x.All().Marked("PasswordBox_Disabled"));
App.ScrollDownTo(PasswordBoxDisabled);
PasswordBoxDisabled.EnterText("Uno platform");

TakeScreenshot("After PasswordBox");
//Assert.IsTrue(NoPasswordBox.GetDependencyPropertyValue<string>("Password") == "Uno platform");
Darsh0307 marked this conversation as resolved.
Show resolved Hide resolved
Assert.AreEqual("", PasswordBoxDisabled.GetDependencyPropertyValue<string>("Password"));

}


}
}
86 changes: 86 additions & 0 deletions Uno.Gallery/Uno.Gallery.UITest/Given_PasswordBox_Material.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using Uno.UITest.Helpers.Queries;
using Uno.UITests.Helpers;

namespace Uno.Gallery.UITests
{
//[Ignore("WIP: M3 Migration")]
Darsh0307 marked this conversation as resolved.
Show resolved Hide resolved
public class Given_PasswordBox_Material : TestBase
{

[Test]
public void WhenPasswordBoxDefault()
{
NavigateToSample("PasswordBox", "Material");

TakeScreenshot("Before PasswordBox");

var passwordBox_Defalut = new QueryEx(x => x.All().Marked("PasswordBox_Default"));
App.ScrollDownTo(passwordBox_Defalut);
passwordBox_Defalut.EnterText("Uno platform");


TakeScreenshot("After PasswordBox");
Assert.AreEqual("Uno platform", passwordBox_Defalut.GetDependencyPropertyValue<string>("Password"));

}

[Test]
public void WhenPasswordBoxDefaultDisabled()
{
NavigateToSample("PasswordBox", "Material");

TakeScreenshot("Before PasswordBox");

var passwordBox_Defalut_Disbaled = new QueryEx(x => x.All().Marked("PasswordBox_Default_Disabled"));
App.ScrollDownTo(passwordBox_Defalut_Disbaled);
passwordBox_Defalut_Disbaled.EnterText("Uno platform");


TakeScreenshot("After PasswordBox");
Assert.AreEqual("", passwordBox_Defalut_Disbaled.GetDependencyPropertyValue<string>("Password"));

}

[Test]
public void WhenPasswordBoxOutlined()
{
NavigateToSample("PasswordBox", "Material");

TakeScreenshot("Before PasswordBox");

var passwordBox_outlined = new QueryEx(x => x.All().Marked("PasswordBox_Outlined"));
App.ScrollDownTo(passwordBox_outlined);
passwordBox_outlined.EnterText("Uno platform");


TakeScreenshot("After PasswordBox");
Assert.AreEqual("Uno platform", passwordBox_outlined.GetDependencyPropertyValue<string>("Password"));

}

[Test]
public void WhenPasswordBoxOutlinedDisabled()
{
NavigateToSample("PasswordBox", "Material");

TakeScreenshot("Before PasswordBox");

var passwordBox_outlined_disabled = new QueryEx(x => x.All().Marked("PasswordBox_Outlined_Disabled"));
App.ScrollDownTo(passwordBox_outlined_disabled);
passwordBox_outlined_disabled.EnterText("Uno platform");


TakeScreenshot("After PasswordBox");
Assert.AreEqual("", passwordBox_outlined_disabled.GetDependencyPropertyValue<string>("Password"));

}


}
}
Loading