Class ScrollRectTests
Inheritance
ScrollRectTests
Implements
IPrebuildSetup
Assembly: UnityEngine.UI.Tests.dll
public class ScrollRectTests : IPrebuildSetup
Methods
Declaration
[Test]
[TestCase(new object[] { true, true, 2, 4, -2, -2 }, TestName = "Should clamp offset")]
[TestCase(new object[] { false, true, 2, 4, 0, -2 }, TestName = "Vertical should clamp offset on one axis")]
[TestCase(new object[] { true, false, 2, 4, -2, 0 }, TestName = "Horizontal should clamp offset on one axis")]
[TestCase(new object[] { false, false, 2, 4, 0, 0 }, TestName = "No axis should not clamp offset")]
[TestCase(new object[] { true, true, 8, 10, 2, 2 }, TestName = "Should clamp negative offset")]
[TestCase(new object[] { false, true, 8, 10, 0, 2 }, TestName = "Vertical should clamp negative offset on one axis")]
[TestCase(new object[] { true, false, 8, 10, 2, 0 }, TestName = "Horizontal should clamp negative offset on one axis")]
[TestCase(new object[] { false, false, 8, 10, 0, 0 }, TestName = "No axis should not clamp negative offset")]
public void CalculateOffsetShouldClamp(bool horizontal, bool vertical, int viewX, float viewY, float resX, float resY)
Parameters
Declaration
[Test]
[TestCase(new object[] { true, true, 2, 4, -2, -2 }, TestName = "Should clamp offset")]
[TestCase(new object[] { false, true, 2, 4, 0, -2 }, TestName = "Vertical should clamp offset on one axis")]
[TestCase(new object[] { true, false, 2, 4, -2, 0 }, TestName = "Horizontal should clamp offset on one axis")]
[TestCase(new object[] { false, false, 2, 4, 0, 0 }, TestName = "No axis should not clamp offset")]
[TestCase(new object[] { true, true, 8, 10, 2, 2 }, TestName = "Should clamp negative offset")]
[TestCase(new object[] { false, true, 8, 10, 0, 2 }, TestName = "Vertical should clamp negative offset on one axis")]
[TestCase(new object[] { true, false, 8, 10, 2, 0 }, TestName = "Horizontal should clamp negative offset on one axis")]
[TestCase(new object[] { false, false, 8, 10, 0, 0 }, TestName = "No axis should not clamp negative offset")]
public void CalculateOffsetUnrestrictedShouldNotClamp(bool horizontal, bool vertical, int viewX, float viewY, float resX, float resY)
Parameters
Declaration
[Test]
public void GetBoundsShouldEncapsulateAllCorners()
Declaration
[UnityTest]
public IEnumerator LateUpdateWithElasticNoOffsetShouldZeroVelocity()
Returns
Declaration
[UnityTest]
[Ignore("Fails")]
public IEnumerator LateUpdateWithElasticShouldDecelerate()
Returns
Declaration
[UnityTest]
public IEnumerator LateUpdateWithInertiaShouldDecelerate()
Returns
Declaration
[UnityTest]
public IEnumerator LateUpdateWithoutInertiaOrElasticShouldZeroVelocity()
Returns
Declaration
[Test]
[TestCase(PointerEventData.InputButton.Left, true, true)]
[TestCase(PointerEventData.InputButton.Left, false, false)]
[TestCase(PointerEventData.InputButton.Right, true, false)]
[TestCase(PointerEventData.InputButton.Middle, true, false)]
public void LeftClickShouldStartDrag(PointerEventData.InputButton button, bool active, bool expectedIsDragging)
Parameters
Declaration
[Test]
[TestCase(PointerEventData.InputButton.Left, true, false)]
[TestCase(PointerEventData.InputButton.Left, false, false)]
[TestCase(PointerEventData.InputButton.Right, false, false)]
[TestCase(PointerEventData.InputButton.Right, true, true)]
[TestCase(PointerEventData.InputButton.Middle, true, true)]
[TestCase(PointerEventData.InputButton.Middle, false, false)]
public void LeftClickUpShouldEndDrag(PointerEventData.InputButton button, bool active, bool expectedIsDragging)
Parameters
Declaration
[UnityTest]
[TestCase(true, ExpectedResult = null)]
[TestCase(false, ExpectedResult = null)]
public IEnumerator OnDisableShouldRemoveListeners(bool isHorizontal)
Parameters
Type |
Name |
Description |
bool |
isHorizontal |
|
Returns
Declaration
[UnityTest]
[TestCase(true, ExpectedResult = null)]
[TestCase(false, ExpectedResult = null)]
public IEnumerator OnEnableShouldAddListeners(bool isHorizontal)
Parameters
Type |
Name |
Description |
bool |
isHorizontal |
|
Returns
OnScrollClampedShouldClampContentAnchoredPosition(MovementType, float, float)
Declaration
[Test]
[Ignore("Tests fail without mocking")]
[TestCase(ScrollRect.MovementType.Clamped, 1, 1)]
[TestCase(ScrollRect.MovementType.Unrestricted, 150, 150)]
[TestCase(ScrollRect.MovementType.Elastic, 150, 150)]
public void OnScrollClampedShouldClampContentAnchoredPosition(ScrollRect.MovementType movementType, float anchoredPosX, float anchoredPosY)
Parameters
OnScrollClampedShouldMoveContentAnchoredPosition(int, int, bool, bool, int, int)
Declaration
[Test]
[TestCase(new object[] { 1, 1, true, true, 1, -1 }, TestName = "Horizontal and vertical scroll")]
[TestCase(new object[] { 1, 1, false, true, 0, -1 }, TestName = "Vertical scroll")]
[TestCase(new object[] { 1, 1, true, false, 1, 0 }, TestName = "Horizontal scroll")]
public void OnScrollClampedShouldMoveContentAnchoredPosition(int scrollDeltaX, int scrollDeltaY, bool horizontal, bool vertical, int expectedPosX, int expectedPosY)
Parameters
Type |
Name |
Description |
int |
scrollDeltaX |
|
int |
scrollDeltaY |
|
bool |
horizontal |
|
bool |
vertical |
|
int |
expectedPosX |
|
int |
expectedPosY |
|
Declaration
[OneTimeTearDown]
public void OneTimeTearDown()
Declaration
[Test]
[TestCase(PointerEventData.InputButton.Left, true)]
[TestCase(PointerEventData.InputButton.Right, false)]
[TestCase(PointerEventData.InputButton.Middle, false)]
public void PotentialDragNeedsLeftClick(PointerEventData.InputButton button, bool expectedEqualsZero)
Parameters
SetNormalizedPositionShouldSetContentLocalPosition()
Declaration
[Test]
public void SetNormalizedPositionShouldSetContentLocalPosition()
Declaration
[Test]
[TestCase(true)]
[TestCase(false)]
public void SettingScrollbarShouldRemoveThenAddListeners(bool testHorizontal)
Parameters
Type |
Name |
Description |
bool |
testHorizontal |
|
Declaration
Declaration
[TearDown]
public void TearDown()
Declaration
[SetUp]
public void TestSetup()
Declaration
[Test]
public void UpdateBoundsShouldPad()
Implements
UnityEngine.TestTools.IPrebuildSetup