summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.UnitTests/AnimationTests.cs
blob: 5b110bebf307bb75884eafac15972ae71da61295 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using NUnit.Framework;
using System.Threading.Tasks;

namespace Xamarin.Forms.Core.UnitTests
{
	[TestFixture]
	public class AnimationTests : BaseTestFixture
	{
		[Test]
		//https://bugzilla.xamarin.com/show_bug.cgi?id=51424
		public async void AnimationRepeats()
		{
			var box = new BoxView();
			Assume.That(box.Rotation, Is.EqualTo(0d));
			var sb = new Animation();
			var animcount = 0;
			var rot45 = new Animation(d =>
			{
				box.Rotation = d;
				if (d > 44)
					animcount++;
			}, box.Rotation, box.Rotation + 45);
			sb.Add(0, .5, rot45);
			Assume.That(box.Rotation, Is.EqualTo(0d));

			var i = 0;
			sb.Commit(box, "foo", length: 100, repeat: () => ++i < 2);

			await Task.Delay(250);
			Assert.That(animcount, Is.EqualTo(2));
		}
	}
}