From 1d4f8f2b5419ef7909af887d202c4ffde47a35c8 Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Tue, 4 Sep 2018 19:08:37 +0900 Subject: [PATCH] [Recorder][Non-ACR][Cleaning code for Recorder.Tests] Change-Id: I60e58864b5fdf989e9da9edc3c51ad18ef19b508 --- .../Tizen.Recorder.Tests/testcase/TSRecorder.cs | 76 +++++++++++++++++----- .../testcase/TSRecordingLimitReachedEventArgs.cs | 2 - 2 files changed, 59 insertions(+), 19 deletions(-) mode change 100755 => 100644 tct-suite-vs/Tizen.Recorder.Tests/testcase/TSRecorder.cs mode change 100755 => 100644 tct-suite-vs/Tizen.Recorder.Tests/testcase/TSRecordingLimitReachedEventArgs.cs diff --git a/tct-suite-vs/Tizen.Recorder.Tests/testcase/TSRecorder.cs b/tct-suite-vs/Tizen.Recorder.Tests/testcase/TSRecorder.cs old mode 100755 new mode 100644 index 25794de..907ad45 --- a/tct-suite-vs/Tizen.Recorder.Tests/testcase/TSRecorder.cs +++ b/tct-suite-vs/Tizen.Recorder.Tests/testcase/TSRecorder.cs @@ -33,10 +33,16 @@ namespace Tizen.Multimedia.Tests /* Test code * Test recording state */ - AudioRecorder.Start(SavePath); - Assert.AreEqual(RecorderState.Recording, AudioRecorder.State, "Recorder should be in recording state"); - await Task.Delay(1000); + using (var eventWaiter = EventAwaiter.Create()) + { + AudioRecorder.AudioStreamStoring += eventWaiter; + + AudioRecorder.Start(SavePath); + Assert.AreEqual(RecorderState.Recording, AudioRecorder.State, "Recorder should be in recording state"); + + await eventWaiter.IsRaisedAsync(); + } /* Test code * Test paused state @@ -356,9 +362,15 @@ namespace Tizen.Multimedia.Tests public async Task Pause_CHECK_STATE() { AudioRecorder.Prepare(); - AudioRecorder.Start(SavePath); - await Task.Delay(1000); + using (var eventWaiter = EventAwaiter.Create()) + { + AudioRecorder.AudioStreamStoring += eventWaiter; + + AudioRecorder.Start(SavePath); + + await eventWaiter.IsRaisedAsync(); + } /* Test code * Test recorder is in Paused state. @@ -377,9 +389,15 @@ namespace Tizen.Multimedia.Tests public async Task Resume_CHECK_STATE() { AudioRecorder.Prepare(); - AudioRecorder.Start(SavePath); - await Task.Delay(1000); + using (var eventWaiter = EventAwaiter.Create()) + { + AudioRecorder.AudioStreamStoring += eventWaiter; + + AudioRecorder.Start(SavePath); + + await eventWaiter.IsRaisedAsync(); + } /* Test code * Test recorder is in Recording state @@ -399,9 +417,15 @@ namespace Tizen.Multimedia.Tests public async Task Commit_CHECK_STATE() { AudioRecorder.Prepare(); - AudioRecorder.Start(SavePath); - await Task.Delay(1000); + using (var eventWaiter = EventAwaiter.Create()) + { + AudioRecorder.AudioStreamStoring += eventWaiter; + + AudioRecorder.Start(SavePath); + + await eventWaiter.IsRaisedAsync(); + } /* Test code * Test recorder is in Ready state. @@ -442,9 +466,15 @@ namespace Tizen.Multimedia.Tests public async Task Unprepare_CHECK_STATE() { AudioRecorder.Prepare(); - AudioRecorder.Start(SavePath); - await Task.Delay(1000); + using (var eventWaiter = EventAwaiter.Create()) + { + AudioRecorder.AudioStreamStoring += eventWaiter; + + AudioRecorder.Start(SavePath); + + await eventWaiter.IsRaisedAsync(); + } AudioRecorder.Commit(); @@ -465,12 +495,19 @@ namespace Tizen.Multimedia.Tests public async Task GetPeakAudioLevel_RETURN_VALUE() { AudioRecorder.Prepare(); - AudioRecorder.Start(SavePath); + + using (var eventWaiter = EventAwaiter.Create()) + { + AudioRecorder.AudioStreamStoring += eventWaiter; + + AudioRecorder.Start(SavePath); + + await eventWaiter.IsRaisedAsync(); + } /* Test code * Test return value of the method. */ - await Task.Delay(1000); double level = AudioRecorder.GetPeakAudioLevel(); Assert.IsNotNull(level, "audiolevel should not be null"); } @@ -500,9 +537,16 @@ namespace Tizen.Multimedia.Tests AudioRecorder.Prepare(); AudioRecorder.TimeLimit = 5; - AudioRecorder.Start(SavePath); - await Task.Delay(1000); + using (var eventWaiter = EventAwaiter.Create()) + { + AudioRecorder.AudioStreamStoring += eventWaiter; + + AudioRecorder.Start(SavePath); + + await eventWaiter.IsRaisedAsync(); + } + /* Test Recording state */ state = Recorder.GetDeviceState(RecorderType.Audio); Assert.AreEqual(state, RecorderDeviceState.Recording, "The device should be in recording state"); @@ -590,8 +634,6 @@ namespace Tizen.Multimedia.Tests AudioRecorder.Prepare(); AudioRecorder.Start(SavePath); - await Task.Delay(1000); - Assert.That(await eventAwaiter.IsRaisedAsync(), "The event should be raised"); } } diff --git a/tct-suite-vs/Tizen.Recorder.Tests/testcase/TSRecordingLimitReachedEventArgs.cs b/tct-suite-vs/Tizen.Recorder.Tests/testcase/TSRecordingLimitReachedEventArgs.cs old mode 100755 new mode 100644 index d6f6e22..889e186 --- a/tct-suite-vs/Tizen.Recorder.Tests/testcase/TSRecordingLimitReachedEventArgs.cs +++ b/tct-suite-vs/Tizen.Recorder.Tests/testcase/TSRecordingLimitReachedEventArgs.cs @@ -28,8 +28,6 @@ namespace Tizen.Multimedia.Tests AudioRecorder.Prepare(); AudioRecorder.Start(SavePath); - await Task.Delay(1000); - return await eventAwaiter.GetResultAsync(); } } -- 2.7.4