|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Globalization; |
|
|
|
using OpenQA.Selenium.Appium; |
|
|
|
using OpenQA.Selenium.Interactions; |
|
|
|
using Xunit; |
|
|
|
@ -15,21 +16,95 @@ namespace Avalonia.IntegrationTests.Appium |
|
|
|
_session = fixture.Session; |
|
|
|
|
|
|
|
var tabs = _session.FindElementByAccessibilityId("MainTabs"); |
|
|
|
var tab = tabs.FindElementByName("SliderTab"); |
|
|
|
var tab = tabs.FindElementByName("Slider"); |
|
|
|
tab.Click(); |
|
|
|
|
|
|
|
var reset = _session.FindElementByAccessibilityId("ResetSliders"); |
|
|
|
reset.Click(); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Horizontal_Changes_Value_Dragging_Thumb_Right() |
|
|
|
{ |
|
|
|
var slider = _session.FindElementByAccessibilityId("HorizontalSlider"); |
|
|
|
var thumb = slider.FindElementByAccessibilityId("thumb"); |
|
|
|
var initialThumbRect = thumb.Rect; |
|
|
|
|
|
|
|
new Actions(_session).ClickAndHold(thumb).MoveByOffset(100, 0).Release().Perform(); |
|
|
|
|
|
|
|
var value = Math.Round(double.Parse(slider.Text, CultureInfo.InvariantCulture)); |
|
|
|
var boundValue = double.Parse( |
|
|
|
_session.FindElementByAccessibilityId("HorizontalSliderValue").Text, |
|
|
|
CultureInfo.InvariantCulture); |
|
|
|
|
|
|
|
Assert.True(value > 50); |
|
|
|
Assert.Equal(value, boundValue); |
|
|
|
|
|
|
|
var currentThumbRect = thumb.Rect; |
|
|
|
Assert.True(currentThumbRect.Left > initialThumbRect.Left); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Horizontal_Changes_Value_Dragging_Thumb_Left() |
|
|
|
{ |
|
|
|
var slider = _session.FindElementByAccessibilityId("HorizontalSlider"); |
|
|
|
var thumb = slider.FindElementByAccessibilityId("thumb"); |
|
|
|
var initialThumbRect = thumb.Rect; |
|
|
|
|
|
|
|
new Actions(_session).ClickAndHold(thumb).MoveByOffset(-100, 0).Release().Perform(); |
|
|
|
|
|
|
|
var value = Math.Round(double.Parse(slider.Text, CultureInfo.InvariantCulture)); |
|
|
|
var boundValue = double.Parse( |
|
|
|
_session.FindElementByAccessibilityId("HorizontalSliderValue").Text, |
|
|
|
CultureInfo.InvariantCulture); |
|
|
|
|
|
|
|
Assert.True(value < 50); |
|
|
|
Assert.Equal(value, boundValue); |
|
|
|
|
|
|
|
var currentThumbRect = thumb.Rect; |
|
|
|
Assert.True(currentThumbRect.Left < initialThumbRect.Left); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Changes_Value_When_Clicking_Increase_Button() |
|
|
|
public void Horizontal_Changes_Value_When_Clicking_Increase_Button() |
|
|
|
{ |
|
|
|
var slider = _session.FindElementByAccessibilityId("Slider"); |
|
|
|
var slider = _session.FindElementByAccessibilityId("HorizontalSlider"); |
|
|
|
var thumb = slider.FindElementByAccessibilityId("thumb"); |
|
|
|
var initialThumbRect = thumb.Rect; |
|
|
|
|
|
|
|
new Actions(_session).MoveToElement(slider).MoveByOffset(100, 0).Click().Perform(); |
|
|
|
|
|
|
|
var value = Math.Round(double.Parse(slider.Text, CultureInfo.InvariantCulture)); |
|
|
|
var boundValue = double.Parse( |
|
|
|
_session.FindElementByAccessibilityId("HorizontalSliderValue").Text, |
|
|
|
CultureInfo.InvariantCulture); |
|
|
|
|
|
|
|
Assert.True(value > 50); |
|
|
|
Assert.Equal(value, boundValue); |
|
|
|
|
|
|
|
var currentThumbRect = thumb.Rect; |
|
|
|
Assert.True(currentThumbRect.Left > initialThumbRect.Left); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Horizontal_Changes_Value_When_Clicking_Decrease_Button() |
|
|
|
{ |
|
|
|
var slider = _session.FindElementByAccessibilityId("HorizontalSlider"); |
|
|
|
var thumb = slider.FindElementByAccessibilityId("thumb"); |
|
|
|
var initialThumbRect = thumb.Rect; |
|
|
|
|
|
|
|
new Actions(_session).MoveToElement(slider).MoveByOffset(-100, 0).Click().Perform(); |
|
|
|
|
|
|
|
// slider.Text gets the Slider value
|
|
|
|
Assert.True(double.Parse(slider.Text) == 30); |
|
|
|
var value = Math.Round(double.Parse(slider.Text, CultureInfo.InvariantCulture)); |
|
|
|
var boundValue = double.Parse( |
|
|
|
_session.FindElementByAccessibilityId("HorizontalSliderValue").Text, |
|
|
|
CultureInfo.InvariantCulture); |
|
|
|
|
|
|
|
new Actions(_session).Click(slider).Perform(); |
|
|
|
Assert.True(value < 50); |
|
|
|
Assert.Equal(value, boundValue); |
|
|
|
|
|
|
|
Assert.Equal(50, Math.Round(double.Parse(slider.Text))); |
|
|
|
var currentThumbRect = thumb.Rect; |
|
|
|
Assert.True(currentThumbRect.Left < initialThumbRect.Left); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|