From 594bb62b83131587e18eee79da5e749d7693a62c Mon Sep 17 00:00:00 2001 From: nam Date: Thu, 11 Oct 2018 15:43:17 +0900 Subject: [PATCH] [MediaPlayer][Non-ACR] fix the TCs to ignore a little diff Change-Id: I797753eb6c1489a77f9d3f0e7585bf516704678b --- .../Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs b/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs index 759166a..c2257db 100755 --- a/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs +++ b/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs @@ -18,6 +18,9 @@ namespace Tizen.Multimedia.Tests } internal static readonly MediaUriSource StreamingSource = new MediaUriSource(PreconditionUtils.STREAMING_URI); + private const long Unit = 1_000_000; /* 1 Millisecond = 1,000,000 Nanoseconds */ + private static long ConvertMillisecondsToNanoseconds(int milliseconds) => milliseconds * Unit; + [Test] [Category("P1")] [Description("Player instantiation")] @@ -861,15 +864,19 @@ namespace Tizen.Multimedia.Tests { var player = await GetPreparedPlayer(); - Assert.That(player.GetPlayPositionNanoseconds(), Is.Zero); + long val1 = ConvertMillisecondsToNanoseconds(1000); + long val2 = ConvertMillisecondsToNanoseconds(5000); - await player.SetPlayPositionNanosecondsAsync(100000000, true); + Assert.That(player.GetPlayPositionNanoseconds(), Is.Zero); - Assert.That(player.GetPlayPositionNanoseconds(), Is.EqualTo(100000000)); + await player.SetPlayPositionNanosecondsAsync(val1, true); - await player.SetPlayPositionNanosecondsAsync(500000000, true); + long diff = Math.Abs(val1 - player.GetPlayPositionNanoseconds()); + Assert.That(diff, Is.LessThan(Unit), $"PlayPosition difference is too big : { diff }"); - Assert.That(player.GetPlayPositionNanoseconds(), Is.EqualTo(500000000)); + await player.SetPlayPositionNanosecondsAsync(val2, true); + diff = Math.Abs(val2 - player.GetPlayPositionNanoseconds()); + Assert.That(diff, Is.LessThan(Unit), $"PlayPosition difference is too big : { diff }"); } [Test] @@ -910,11 +917,11 @@ namespace Tizen.Multimedia.Tests { var player = await GetPreparedPlayer(); - const int targetPos = 7000000; + long targetPos = ConvertMillisecondsToNanoseconds(7000); await player.SetPlayPositionNanosecondsAsync(targetPos, false); - Assert.That(Math.Abs(targetPos - player.GetPlayPositionNanoseconds()), Is.LessThan(1000000), + Assert.That(Math.Abs(targetPos - player.GetPlayPositionNanoseconds()), Is.LessThan(Unit), "The difference is too big."); } @@ -929,11 +936,12 @@ namespace Tizen.Multimedia.Tests { var player = await GetPreparedPlayer(); - const int targetPos = 7000000; + long targetPos = ConvertMillisecondsToNanoseconds(7000); await player.SetPlayPositionNanosecondsAsync(targetPos, true); - Assert.That(player.GetPlayPositionNanoseconds(), Is.EqualTo(targetPos)); + Assert.That(Math.Abs(targetPos - player.GetPlayPositionNanoseconds()), Is.LessThan(Unit), + "The difference is too big."); } [Test] @@ -976,7 +984,7 @@ namespace Tizen.Multimedia.Tests { var player = await GetPreparedPlayer(); - var task = await AsyncWrapper.Wrap(() => player.SetPlayPositionNanosecondsAsync(40000000000, false)); + var task = await AsyncWrapper.Wrap(() => player.SetPlayPositionNanosecondsAsync(40_000_000_000, false)); Assert.That(() => task, Throws.TypeOf()); } -- 2.7.4