From 8a771855db300bd73902d58d97c5822da517dc29 Mon Sep 17 00:00:00 2001 From: Daniil Pavliuchyk Date: Wed, 22 Feb 2023 15:41:30 +0200 Subject: [PATCH] Add tests --- samples/IntegrationTestApp/MainWindow.axaml | 10 ++++ .../RadioButtonTests.cs | 48 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 tests/Avalonia.IntegrationTests.Appium/RadioButtonTests.cs diff --git a/samples/IntegrationTestApp/MainWindow.axaml b/samples/IntegrationTestApp/MainWindow.axaml index 353e01dca7..58e8aef1e9 100644 --- a/samples/IntegrationTestApp/MainWindow.axaml +++ b/samples/IntegrationTestApp/MainWindow.axaml @@ -56,6 +56,16 @@ + + + Sample RadioButton + + Three States: Option 1 + Three States: Option 2 + + + + Unchecked diff --git a/tests/Avalonia.IntegrationTests.Appium/RadioButtonTests.cs b/tests/Avalonia.IntegrationTests.Appium/RadioButtonTests.cs new file mode 100644 index 0000000000..5bd0a05155 --- /dev/null +++ b/tests/Avalonia.IntegrationTests.Appium/RadioButtonTests.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using OpenQA.Selenium.Appium; +using Xunit; + +namespace Avalonia.IntegrationTests.Appium +{ + [Collection("Default")] + public class RadioButtonTests + { + private readonly AppiumDriver _session; + + public RadioButtonTests(TestAppFixture fixture) + { + _session = fixture.Session; + + var tabs = _session.FindElementByAccessibilityId("MainTabs"); + tabs.FindElementByName("RadioButton").Click(); + } + + + [Fact] + public void RadioButton_IsChecked_True_When_Clicked() + { + var button = _session.FindElementByAccessibilityId("BasicRadioButton"); + Assert.False(button.GetIsChecked()); + button.Click(); + Assert.True(button.GetIsChecked()); + } + + [Fact] + public void ThreeState_RadioButton_IsChecked_False_When_Other_ThreeState_RadioButton_Checked() + { + var button1 = _session.FindElementByAccessibilityId("ThreeStatesRadioButton1"); + var button2 = _session.FindElementByAccessibilityId("ThreeStatesRadioButton2"); + Assert.True(button1.GetIsChecked()); + Assert.False(button2.GetIsChecked()); + button2.Click(); + Assert.False(button1.GetIsChecked()); + Assert.True(button2.GetIsChecked()); + } + + } +}