From: ruble Date: Tue, 1 Oct 2019 09:22:28 +0000 (+0900) Subject: [MediaPlayer][TCSACR-281] add TCs for the type of an audio codec X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab8d143f67e0d7df3bd1b5336ba3a7688659d348;p=test%2Ftct%2Fcsharp%2Fapi.git [MediaPlayer][TCSACR-281] add TCs for the type of an audio codec Change-Id: I8f82d82d986c04810f75b0d8318b9c068a0e0a1f --- diff --git a/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSAudioEffect.cs b/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSAudioEffect.cs index 036ffac..828e635 100755 --- a/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSAudioEffect.cs +++ b/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSAudioEffect.cs @@ -26,6 +26,20 @@ namespace Tizen.Multimedia.Tests } } + private void CheckTestability() + { + try + { + GetIdlePlayer().AudioCodecType = CodecType.Hardware; + if (_audioEffect.IsAvailable == true) + Assert.Pass($"Audio effect is available. NotAvailableException can not occur."); + } + catch (CodecNotSupportedException) + { + Assert.Pass($"HW Codec is not supported. It is not testable."); + } + } + [SetUp] public void SetUp() { @@ -208,5 +222,56 @@ namespace Tizen.Multimedia.Tests Assert.That(() => _audioEffect.IsAvailable, Throws.InvalidOperationException); } + [Test] + [Category("P2")] + [Description("Clear throws exception if it is unavailable")] + [Property("SPEC", "Tizen.Multimedia.AudioEffect.Clear M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public void Clear_THROWS_IF_AVAILABLE() + { + CheckTestability(); + Assert.That(() => _audioEffect.Clear(), Throws.TypeOf()); + } + + [Test] + [Category("P2")] + [Description("Count throws exception if it is unavailable")] + [Property("SPEC", "Tizen.Multimedia.AudioEffect.Count A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public void Count_THROWS_IF_AVAILABLE() + { + CheckTestability(); + Assert.That(() => _audioEffect.Count, Throws.TypeOf()); + } + + [Test] + [Category("P2")] + [Description("BandLevelRange throws exception if it is unavailable")] + [Property("SPEC", "Tizen.Multimedia.AudioEffect.BandLevelRange A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public void BandLevelRange_THROWS_IF_AVAILABLE() + { + CheckTestability(); + Assert.That(() => _audioEffect.BandLevelRange, Throws.TypeOf()); + } + + [Test] + [Category("P2")] + [Description("IsAvailable throws exception if it is unavailable")] + [Property("SPEC", "Tizen.Multimedia.AudioEffect.IsAvailable A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public void IsAvailable_THROWS_IF_AVAILABLE() + { + CheckTestability(); + Assert.That(() => _audioEffect.IsAvailable, Throws.TypeOf()); + } } } diff --git a/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs b/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs index 411cd4a..2bb26b6 100755 --- a/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs +++ b/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs @@ -479,7 +479,23 @@ namespace Tizen.Multimedia.Tests [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] public void ReplayGain_DEFAULT() { - Assert.That(TestPlayer.ReplayGain, Is.False); + bool checkEquals = false; + try + { + checkEquals = TestPlayer.ReplayGain.Equals(false); + } + catch (NotAvailableException) + { + CodecType codecType = TestPlayer.AudioCodecType; + if (codecType == CodecType.Hardware) + Assert.Pass($"It could be not available depending on the platform capabilities"); + else + Assert.Fail($"exeption occurs even though software codec is used."); + } + finally + { + Assert.That(checkEquals, Is.EqualTo(true)); + } } [Test] @@ -491,10 +507,26 @@ namespace Tizen.Multimedia.Tests [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] public void ReplayGain_SET_GET() { - const bool newValue = true; + bool checkEquals = false; + try + { + const bool newValue = true; - TestPlayer.ReplayGain = newValue; - Assert.That(TestPlayer.ReplayGain, Is.EqualTo(newValue)); + TestPlayer.ReplayGain = newValue; + checkEquals = TestPlayer.ReplayGain.Equals(newValue); + } + catch (NotAvailableException) + { + CodecType codecType = TestPlayer.AudioCodecType; + if (codecType == CodecType.Hardware) + Assert.Pass($"It could be not available depending on the platform capabilities"); + else + Assert.Fail($"exeption occurs even though software codec is used."); + } + finally + { + Assert.That(checkEquals, Is.EqualTo(true)); + } } @@ -2318,11 +2350,27 @@ namespace Tizen.Multimedia.Tests [Description("AudioPitchEnabled check default value")] [Property("SPEC", "Tizen.Multimedia.Player.AudioPitchEnabled A")] [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRW")] + [Property("CRITERIA", "PDV")] [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] public void AudioPitchEnabled_DEFAULT() { - Assert.That(TestPlayer.AudioPitchEnabled, Is.EqualTo(false)); + bool checkEquals = false; + try + { + checkEquals = TestPlayer.AudioPitchEnabled.Equals(false); + } + catch (NotAvailableException) + { + CodecType codecType = TestPlayer.AudioCodecType; + if (codecType == CodecType.Hardware) + Assert.Pass($"It could be not available depending on the platform capabilities"); + else + Assert.Fail($"exeption occurs even though software codec is used."); + } + finally + { + Assert.That(checkEquals, Is.EqualTo(true)); + } } [Test] @@ -2334,8 +2382,22 @@ namespace Tizen.Multimedia.Tests [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] public void AudioPitchEnabled_CHECK() { - TestPlayer.AudioPitchEnabled = true; - Assert.That(TestPlayer.AudioPitchEnabled, Is.EqualTo(true)); + try + { + TestPlayer.AudioPitchEnabled = true; + } + catch (NotAvailableException) + { + CodecType codecType = TestPlayer.AudioCodecType; + if (codecType == CodecType.Hardware) + Assert.Pass($"It could be not available depending on the platform capabilities"); + else + Assert.Fail($"exeption occurs even though software codec is used."); + } + finally + { + Assert.That(TestPlayer.AudioPitchEnabled, Is.EqualTo(true)); + } } [Test] @@ -2382,12 +2444,26 @@ namespace Tizen.Multimedia.Tests [Description("AudioPitch check default value")] [Property("SPEC", "Tizen.Multimedia.Player.AudioPitch A")] [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRW")] + [Property("CRITERIA", "PDV")] [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] public void AudioPitch_DEFAULT() { - TestPlayer.AudioPitchEnabled = true; - Assert.That(TestPlayer.AudioPitch, Is.EqualTo(1)); + try + { + TestPlayer.AudioPitchEnabled = true; + } + catch (NotAvailableException) + { + CodecType codecType = TestPlayer.AudioCodecType; + if (codecType == CodecType.Hardware) + Assert.Pass($"It could be not available depending on the platform capabilities"); + else + Assert.Fail($"exeption occurs even though software codec is used."); + } + finally + { + Assert.That(TestPlayer.AudioPitch, Is.EqualTo(1)); + } } [Test] @@ -2399,12 +2475,24 @@ namespace Tizen.Multimedia.Tests [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] public void AudioPitch_CHECK() { - const float value = 1.212F; - - TestPlayer.AudioPitchEnabled = true; - TestPlayer.AudioPitch = value; - - Assert.That(TestPlayer.AudioPitch, Is.EqualTo(value)); + try + { + TestPlayer.AudioPitchEnabled = true; + } + catch (NotAvailableException) + { + CodecType codecType = TestPlayer.AudioCodecType; + if (codecType == CodecType.Hardware) + Assert.Pass($"It could be not available depending on the platform capabilities"); + else + Assert.Fail($"exeption occurs even though software codec is used."); + } + finally + { + const float value = 1.212F; + TestPlayer.AudioPitch = value; + Assert.That(TestPlayer.AudioPitch, Is.EqualTo(value)); + } } [Test] @@ -2416,12 +2504,24 @@ namespace Tizen.Multimedia.Tests [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] public void AudioPitch_MIN_VALUE() { - const float value = 0.5F; - - TestPlayer.AudioPitchEnabled = true; - TestPlayer.AudioPitch = value; - - Assert.That(TestPlayer.AudioPitch, Is.EqualTo(value)); + try + { + TestPlayer.AudioPitchEnabled = true; + } + catch (NotAvailableException) + { + CodecType codecType = TestPlayer.AudioCodecType; + if (codecType == CodecType.Hardware) + Assert.Pass($"It could be not available depending on the platform capabilities"); + else + Assert.Fail($"exeption occurs even though software codec is used."); + } + finally + { + const float value = 0.5F; + TestPlayer.AudioPitch = value; + Assert.That(TestPlayer.AudioPitch, Is.EqualTo(value)); + } } [Test] @@ -2433,12 +2533,24 @@ namespace Tizen.Multimedia.Tests [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] public void AudioPitch_MAX_VALUE() { - const float value = 2.0F; - - TestPlayer.AudioPitchEnabled = true; - TestPlayer.AudioPitch = value; - - Assert.That(TestPlayer.AudioPitch, Is.EqualTo(value)); + try + { + TestPlayer.AudioPitchEnabled = true; + } + catch (NotAvailableException) + { + CodecType codecType = TestPlayer.AudioCodecType; + if (codecType == CodecType.Hardware) + Assert.Pass($"It could be not available depending on the platform capabilities"); + else + Assert.Fail($"exeption occurs even though software codec is used."); + } + finally + { + const float value = 2.0F; + TestPlayer.AudioPitch = value; + Assert.That(TestPlayer.AudioPitch, Is.EqualTo(value)); + } } [Test] @@ -2506,9 +2618,20 @@ namespace Tizen.Multimedia.Tests public async Task AudioDataDecoded_CHECK() { var player = GetIdlePlayer(); - player.SetSource(Constants.AudioFileSource); - player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.NoSyncAndDeinterleave); + + try + { + player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.NoSyncAndDeinterleave); + } + catch (NotAvailableException) + { + CodecType codecType = TestPlayer.AudioCodecType; + if (codecType == CodecType.Hardware) + Assert.Pass($"It could be not available depending on the platform capabilities"); + else + Assert.Fail($"exeption occurs even though software codec is used."); + } using (var eventWaiter = EventAwaiter.Create()) { @@ -2543,9 +2666,20 @@ namespace Tizen.Multimedia.Tests public async Task AudioDataDecoded_CHECK_WITHOUT_FORMAT() { var player = GetIdlePlayer(); - player.SetSource(Constants.AudioFileSource); - player.EnableExportingAudioData(null, PlayerAudioExtractOption.Default); + + try + { + player.EnableExportingAudioData(null, PlayerAudioExtractOption.Default); + } + catch (NotAvailableException) + { + CodecType codecType = TestPlayer.AudioCodecType; + if (codecType == CodecType.Hardware) + Assert.Pass($"It could be not available depending on the platform capabilities"); + else + Assert.Fail($"exeption occurs even though software codec is used."); + } using (var eventWaiter = EventAwaiter.Create()) { @@ -2580,12 +2714,28 @@ namespace Tizen.Multimedia.Tests public void EnableExportingAudioData_CHECK() { var player = GetIdlePlayer(); - player.SetSource(Constants.AudioFileSource); - Assert.That(() => player.EnableExportingAudioData(_audioFormat,PlayerAudioExtractOption.Default), Throws.Nothing); - Assert.That(() => player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.NoSyncWithClock), Throws.Nothing); - Assert.That(() => player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.Deinterleave), Throws.Nothing); - Assert.That(() => player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.NoSyncAndDeinterleave), Throws.Nothing); + try + { + player.SetSource(Constants.AudioFileSource); + + player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.Default); + player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.NoSyncWithClock); + player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.Deinterleave); + player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.NoSyncAndDeinterleave); + } + catch (NotAvailableException) + { + CodecType codecType = player.AudioCodecType; + if (codecType == CodecType.Hardware) + Assert.Pass($"It could be not available depending on the platform capabilities"); + else + Assert.Fail($"exeption occurs even though software codec is used."); + } + catch (Exception) + { + Assert.Fail("It should not throw exception."); + } } [Test] @@ -2657,12 +2807,27 @@ namespace Tizen.Multimedia.Tests [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] public async Task DisableExportingAudioData_CHECK() { - var player = GetIdlePlayer(); - Assert.That(() => player.DisableExportingAudioData(), Throws.Nothing); + try + { + var player = GetIdlePlayer(); + player.DisableExportingAudioData(); - player.SetSource(Constants.AudioFileSource); - await player.PrepareAsync(); - Assert.That(() => player.DisableExportingAudioData(), Throws.Nothing); + player.SetSource(Constants.AudioFileSource); + await player.PrepareAsync(); + player.DisableExportingAudioData(); + } + catch (NotAvailableException) + { + CodecType codecType = TestPlayer.AudioCodecType; + if (codecType == CodecType.Hardware) + Assert.Pass($"It could be not available depending on the platform capabilities"); + else + Assert.Fail($"exeption occurs even though software codec is used."); + } + catch (Exception) + { + Assert.Fail("It should not throw exception."); + } } [Test] @@ -2713,5 +2878,59 @@ namespace Tizen.Multimedia.Tests Assert.False(FeatureChecker.IsSupported(Features.AudioOffload), "NotSupportedException shouldn't be thrown."); } } + + #region CodecType + [Test] + [Category("P1")] + [Description("Check AudioCodecType does not throw exceptions")] + [Property("SPEC", "Tizen.Multimedia.Player.AudioCodecType A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public void AudioCodecType_CHECK() + { + TestPlayer.AudioCodecType = CodecType.Software; + Assert.That(TestPlayer.AudioCodecType, Is.EqualTo(CodecType.Software)); + } + + [Test] + [Category("P2")] + [Description("AudioCodecType throws exception if the player is in a not valid state")] + [Property("SPEC", "Tizen.Multimedia.Player.AudioCodecType A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public async Task AudioCodecType_THROWS_IF_NOT_VALID_STATE() + { + var player = await GetPreparedPlayer(); + Assert.That(() => player.AudioCodecType = CodecType.Hardware, Throws.InvalidOperationException); + } + + [Test] + [Category("P2")] + [Description("AudioCodecType throw exception if the param is not valid")] + [Property("SPEC", "Tizen.Multimedia.Player.AudioCodecType M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public void AudioCodecType_THROWS_IF_PARAM_NOT_VALID() + { + var player = GetIdlePlayer(); + Assert.That(() => player.AudioCodecType = (CodecType)5, Throws.ArgumentException); + } + + [Test] + [Category("P2")] + [Description("Any attempt to access the AudioCodecType if the player has been disposed of")] + [Property("SPEC", "Tizen.Multimedia.Player.AudioCodecType A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public void AudioCodecType_DISPOSED() + { + GetIdlePlayer().Dispose(); + Assert.That(() => TestPlayer.AudioCodecType = CodecType.Hardware, Throws.TypeOf()); + } + #endregion } }