Skip to content
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
2 changes: 1 addition & 1 deletion Tests/Runtime/Operators/UguiDoubleClickOperatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public async Task OperateAsync_DoubleClickSequenceAndTiming_CorrectInterval()

Assert.That(spy.ClickCount, Is.EqualTo(2));
var interval = (spy.ClickTimestamps[1] - spy.ClickTimestamps[0]).TotalMilliseconds;
Assert.That(interval, Is.GreaterThan(49).And.LessThan(200));
Assert.That(interval, Is.GreaterThan(17).And.LessThan(200));
}

[Test]
Expand Down
5 changes: 4 additions & 1 deletion Tests/Runtime/Operators/UguiDragAndDropOperatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace TestHelper.UI.Operators
[TestFixture]
public class UguiDragAndDropOperatorTest
{
private const int RandomTestRepeatCount = 10;

private readonly IOperator _sut = new UguiDragAndDropOperator();
private Vector3 _objectPosition;

Expand Down Expand Up @@ -263,6 +265,7 @@ public async Task OperateAsync_ExistDropHandlerObject_DropOnTarget()

[Test]
[LoadScene("../../Scenes/Canvas.unity")]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_NotExistDropTarget_DropOnRandomScreenPoint()
{
var dragHandler = CreateSpyDragHandler();
Expand All @@ -278,7 +281,7 @@ public async Task OperateAsync_NotExistDropTarget_DropOnRandomScreenPoint()
Assert.That(dragHandler.WasInitializePotentialDrag, Is.True);
Assert.That(dragHandler.WasBeginDrag, Is.True);
Assert.That(dragHandler.WasEndDrag, Is.True);
Assert.That(dragHandler.LastDragPosition, Is.Not.EqualTo(default(Vector2)));
Assert.That(dragHandler.LastDragPosition, Is.Not.EqualTo(SpyOnDragHandler.LastDragPositionInitialValue));
Assert.That(pointerUpHandler.WasOnPointerUp, Is.True);
}

Expand Down
13 changes: 7 additions & 6 deletions Tests/Runtime/Operators/UguiScrollWheelOperatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace TestHelper.UI.Operators
public class UguiScrollWheelOperatorTest
{
private const string TestScene = "../../Scenes/ScrollViews.unity";
private const int RandomTestRepeatCount = 10;

private readonly IOperator _sut = new UguiScrollWheelOperator();
private GameObject _scrollView;
Expand Down Expand Up @@ -341,7 +342,7 @@ public async Task OperateAsync_WithDestination_Scrolled(float x, float y)

[Test]
[LoadScene(TestScene)]
[Repeat(10)]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_WithoutDirectionAndDistance_ScrollRectBoth_RandomScrolling()
{
var scrollRect = _scrollView.GetComponent<ScrollRect>();
Expand All @@ -356,7 +357,7 @@ public async Task OperateAsync_WithoutDirectionAndDistance_ScrollRectBoth_Random

[Test]
[LoadScene(TestScene)]
[Repeat(10)]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_WithoutDirectionAndDistance_ScrollRectHorizontal_RandomScrollingHorizontal()
{
var spyLogger = new SpyLogger();
Expand All @@ -369,7 +370,7 @@ public async Task OperateAsync_WithoutDirectionAndDistance_ScrollRectHorizontal_

[Test]
[LoadScene(TestScene)]
[Repeat(10)]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_WithoutDirectionAndDistance_ScrollRectVertical_RandomScrollingVertical()
{
var spyLogger = new SpyLogger();
Expand All @@ -382,7 +383,7 @@ public async Task OperateAsync_WithoutDirectionAndDistance_ScrollRectVertical_Ra

[Test]
[LoadScene(TestScene)]
[Repeat(10)]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_WithoutDirectionAndDistance_ScrollbarHorizontal_RandomScrollingHorizontal()
{
var spyLogger = new SpyLogger();
Expand All @@ -395,7 +396,7 @@ public async Task OperateAsync_WithoutDirectionAndDistance_ScrollbarHorizontal_R

[Test]
[LoadScene(TestScene)]
[Repeat(10)]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_WithoutDirectionAndDistance_ScrollbarVertical_RandomScrollingVertical()
{
var spyLogger = new SpyLogger();
Expand All @@ -408,7 +409,7 @@ public async Task OperateAsync_WithoutDirectionAndDistance_ScrollbarVertical_Ran

[Test]
[LoadScene(TestScene)]
[Repeat(10)]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_WithoutDirectionAndDistance_NotScrollRectOrScrollbar_RandomScrolling()
{
var gameObject = new GameObject(null, typeof(Image));
Expand Down
23 changes: 12 additions & 11 deletions Tests/Runtime/Operators/UguiSwipeOperatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace TestHelper.UI.Operators
public class UguiSwipeOperatorTest
{
private const string TestScene = "../../Scenes/ScrollViews.unity";
private const int RandomTestRepeatCount = 10;

private readonly ISwipeOperator _sut = new UguiSwipeOperator();
private GameObject _scrollView;
Expand Down Expand Up @@ -359,15 +360,15 @@ public async Task OperateAsync_WithDirection_Swiped(Vector2 direction, int dista
[LoadScene(TestScene)]
public async Task OperateAsync_OnDragCalled()
{
var spyEventHandler = _scrollView.AddComponent<SpyOnDragHandler>();
var spyDragHandler = _scrollView.AddComponent<SpyOnDragHandler>();

var sut = new UguiSwipeOperator();
await sut.OperateAsync(_scrollView, Vector2.up);

Assert.That(spyEventHandler.WasInitializePotentialDrag, Is.True);
Assert.That(spyEventHandler.WasBeginDrag, Is.True);
Assert.That(spyEventHandler.WasEndDrag, Is.True);
Assert.That(spyEventHandler.LastDragPosition, Is.Not.EqualTo(Vector2.zero));
Assert.That(spyDragHandler.WasInitializePotentialDrag, Is.True);
Assert.That(spyDragHandler.WasBeginDrag, Is.True);
Assert.That(spyDragHandler.WasEndDrag, Is.True);
Assert.That(spyDragHandler.LastDragPosition, Is.Not.EqualTo(SpyOnDragHandler.LastDragPositionInitialValue));
}

[Test]
Expand All @@ -386,7 +387,7 @@ public async Task OperateAsync_OnPointerDownAndUpCalled()

[Test]
[LoadScene(TestScene)]
[Repeat(10)]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_WithoutDirection_ScrollRectBoth_RandomSwipe()
{
const int SwipeDistance = 200;
Expand All @@ -402,7 +403,7 @@ public async Task OperateAsync_WithoutDirection_ScrollRectBoth_RandomSwipe()

[Test]
[LoadScene(TestScene)]
[Repeat(10)]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_WithoutDirection_ScrollRectHorizontal_RandomSwipeHorizontal()
{
var spyLogger = new SpyLogger();
Expand All @@ -415,7 +416,7 @@ public async Task OperateAsync_WithoutDirection_ScrollRectHorizontal_RandomSwipe

[Test]
[LoadScene(TestScene)]
[Repeat(10)]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_WithoutDirection_ScrollRectVertical_RandomSwipeVertical()
{
var spyLogger = new SpyLogger();
Expand All @@ -428,7 +429,7 @@ public async Task OperateAsync_WithoutDirection_ScrollRectVertical_RandomSwipeVe

[Test]
[LoadScene(TestScene)]
[Repeat(10)]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_WithoutDirection_ScrollbarHorizontal_RandomSwipeHorizontal()
{
var spyLogger = new SpyLogger();
Expand All @@ -441,7 +442,7 @@ public async Task OperateAsync_WithoutDirection_ScrollbarHorizontal_RandomSwipeH

[Test]
[LoadScene(TestScene)]
[Repeat(10)]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_WithoutDirection_ScrollbarVertical_RandomSwipeVertical()
{
var spyLogger = new SpyLogger();
Expand All @@ -454,7 +455,7 @@ public async Task OperateAsync_WithoutDirection_ScrollbarVertical_RandomSwipeVer

[Test]
[LoadScene(TestScene)]
[Repeat(10)]
[Repeat(RandomTestRepeatCount)]
public async Task OperateAsync_WithoutDirection_NotScrollRectOrScrollbar_RandomSwipe()
{
const int SwipeDistance = 200;
Expand Down
4 changes: 3 additions & 1 deletion Tests/Runtime/TestDoubles/SpyOnDragHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ namespace TestHelper.UI.TestDoubles
public class SpyOnDragHandler : MonoBehaviour, IInitializePotentialDragHandler, IBeginDragHandler, IEndDragHandler,
IDragHandler
{
public static readonly Vector2 LastDragPositionInitialValue = new Vector2(float.MinValue, float.MinValue);

public bool WasInitializePotentialDrag { get; private set; }
public bool WasBeginDrag { get; private set; }
public bool WasEndDrag { get; private set; }
public Vector2 LastDragPosition { get; private set; }
public Vector2 LastDragPosition { get; private set; } = LastDragPositionInitialValue;

private Image _image;
private GameObject _draggingObject;
Expand Down