public void Setup() { SIL.Reporting.ErrorReport.IsOkToInteractWithUser = false; _tempAudioFile = MediaFileInfoTests.GetLongerTestAudioFile(); _timeTier = new TimeTier(_tempAudioFile); _timeTier.AddSegment(0f, 10f); _timeTier.AddSegment(10f, 20f); _timeTier.AddSegment(20f, 30f); _textTier = new TextTier(TextTier.ElanTranscriptionTierId); var annotationFile = new Mock <AnnotationComponentFile>(); annotationFile.Setup(a => a.Tiers).Returns(new TierCollection { _timeTier, _textTier }); _componentFile = new Mock <ComponentFile>(); _componentFile.Setup(f => f.PathToAnnotatedFile).Returns(_tempAudioFile); _componentFile.Setup(f => f.GetAnnotationFile()).Returns(annotationFile.Object); CreateNewModel(); Directory.CreateDirectory(_model.OralAnnotationsFolder); Assert.IsNotNull(_model.OrigWaveStream); }
public void LoadAndPlayFile_FolderHasNonAsciiCharacter_Plays() { var source = MediaFileInfoTests.GetShortTestAudioFile(); using (var folder = new TemporaryFolder("ффSayMoreMediaModelTest")) { var pathname = Path.Combine(folder.Path, "normal.wav"); if (File.Exists(pathname)) { File.Delete(pathname); } File.Move(source, pathname); _model.LoadFile(pathname); _model.SetVolume(0.01f); var logger = new DebugLogger(); ReflectionHelper.SetProperty(_model, "DebugOutput", logger); _model.PlaybackEnded += delegate { _model = null; File.Delete(pathname); }; _model.Play(); while (_model != null) { Thread.Sleep(10); } Assert.IsTrue(logger.GetText().Contains("Starting playback...")); } }
public void Save_CanReadSavedFile() { var mediafile = MediaFileInfoTests.GetShortTestAudioFile(); var expectedEafFile = AnnotationFileHelper.ComputeEafFileNameFromOralAnnotationFile(mediafile); try { var savedEafFile = _collection.Save(mediafile); Assert.AreEqual(expectedEafFile, savedEafFile); var tiers = AnnotationFileHelper.Load(savedEafFile).GetTierCollection(); // We expect only 3 tiers in the saved file, because the AnnotationFileHelper only saves // the Transcription and Free Translation tiers. The "otherTextTier" is discarded. Assert.AreEqual(3, tiers.Count); for (var i = 0; i < tiers.Count; i++) { CheckTier(_collection[i], tiers[i]); } } finally { try { File.Delete(mediafile); } catch { } try { File.Delete(expectedEafFile); } catch { } } }
public void Setup() { _helper = new FLExTextExporter(null, "Homer", null, "en", "fr", "filename1", "filename2"); var tempMediaPath = MediaFileInfoTests.GetLongerTestAudioFile(); _tempFolder = new TemporaryFolder("TierCollectionTests"); _mediaFile = Path.Combine(_tempFolder.Path, "mediaFile.wav"); File.Move(tempMediaPath, _mediaFile); }
public void Setup() { _tempFolder = new TemporaryFolder("ConvertMediaDlgViewModelTests"); _testAudioFileName = MediaFileInfoTests.GetLongerTestAudioFile(); var destFile = Path.Combine(_tempFolder.Path, "test.wav"); File.Move(_testAudioFileName, destFile); _testAudioFileName = destFile; _model = new ConvertMediaDlgViewModel(_testAudioFileName, ConvertMediaDlg.GetFactoryExtractToMp3AudioConversionName()); }
public void Setup() { var tempMediaPath = MediaFileInfoTests.GetLongerTestAudioFile(); _tempFolder = new TemporaryFolder("TierCollectionTests"); var mediaFile = Path.Combine(_tempFolder.Path, "mediaFile.wav"); File.Move(tempMediaPath, mediaFile); _collection = new TierCollection(mediaFile); _collection.Clear(); var timeTier = new TimeTier("timeTier", mediaFile); _collection.Add(timeTier); var transcriptionTier = new TextTier(TextTier.ElanTranscriptionTierId); _collection.Add(transcriptionTier); var translationTier = new TextTier(TextTier.ElanTranslationTierId); _collection.Add(translationTier); var otherTextTier = new TextTier("otherTextTier"); _collection.Add(otherTextTier); timeTier.AddSegment(10f, 20f); timeTier.AddSegment(20f, 30f); timeTier.AddSegment(30f, 40f); transcriptionTier.AddSegment("trans1"); transcriptionTier.AddSegment("trans2"); transcriptionTier.AddSegment("trans3"); translationTier.AddSegment("free1"); translationTier.AddSegment("free2"); translationTier.AddSegment(null); otherTextTier.AddSegment("other1"); otherTextTier.AddSegment(null); otherTextTier.AddSegment(null); Assert.AreEqual(mediaFile, _collection.AnnotatedMediaFile); Assert.AreEqual(4, _collection.Count); }
/// ------------------------------------------------------------------------------------ private string LoadMediaFile() { var file = MediaFileInfoTests.GetTestVideoFile(); Assert.IsTrue(File.Exists(file)); try { _model.LoadFile(file); } catch { File.Delete(file); throw; } return(file); }
public void Setup() { var tempMediaPath = MediaFileInfoTests.GetLongerTestAudioFile(); _tempFolder = new TemporaryFolder("TierCollectionTests"); var mediaFile = Path.Combine(_tempFolder.Path, "mediaFile.wav"); File.Move(tempMediaPath, mediaFile); _tier = new TimeTier("test tier", mediaFile); _tier.AddSegment(10f, 20f); _tier.AddSegment(20f, 30f); _tier.AddSegment(30f, 40f); Assert.AreEqual("test tier", _tier.Id); Assert.AreEqual(string.Empty, _tier.DisplayName); Assert.AreEqual(mediaFile, _tier.MediaFileName); Assert.AreEqual(Path.Combine(_tempFolder.Path, "mediaFile.wav_Annotations"), _tier.SegmentFileFolder); Assert.IsInstanceOf <AudioWaveFormColumn>(_tier.GridColumn); }
public void LoadAndPlayFile_FileNameHasAsciiCharacter_Plays() { var pathname = MediaFileInfoTests.GetShortTestAudioFile(); _model.LoadFile(pathname); _model.SetVolume(0.01f); var logger = new DebugLogger(); ReflectionHelper.SetProperty(_model, "DebugOutput", logger); _model.PlaybackEnded += delegate { _model = null; File.Delete(pathname); }; _model.Play(); while (_model != null) { Thread.Sleep(10); } Assert.IsTrue(logger.GetText().Contains("Starting playback...")); }
public void Setup() { _tempAudioFile = MediaFileInfoTests.GetLongerTestAudioFile(); var tier = new TimeTier(_tempAudioFile); tier.AddSegment(0f, 5f); tier.AddSegment(5f, 10f); tier.AddSegment(15f, 20f); tier.AddSegment(25f, 30f); var annotationFile = new Mock <AnnotationComponentFile>(); annotationFile.Setup(a => a.Tiers).Returns(new TierCollection { tier }); _componentFile = new Mock <ComponentFile>(); _componentFile.Setup(f => f.PathToAnnotatedFile).Returns(_tempAudioFile); _componentFile.Setup(f => f.GetAnnotationFile()).Returns(annotationFile.Object); _model = OralAnnotationRecorderDlgViewModel.Create(_componentFile.Object, AudioRecordingType.Careful); }
public void Save_CanReadSavedFile() { var mediafile = MediaFileInfoTests.GetShortTestAudioFile(); var expectedEafFile = AnnotationFileHelper.ComputeEafFileNameFromOralAnnotationFile(mediafile); try { var savedEafFile = _collection.Save(mediafile); Assert.AreEqual(expectedEafFile, savedEafFile); var tiers = AnnotationFileHelper.Load(savedEafFile).GetTierCollection(); Assert.AreEqual(4, tiers.Count); for (int i = 0; i < tiers.Count; i++) { CheckTier(_collection[i], tiers[i]); } } catch { } finally { try { File.Delete(mediafile); } catch { } try { File.Delete(expectedEafFile); } catch { } } }
public void SetUp() { _testAudioFileName = MediaFileInfoTests.GetLongerTestAudioFile(); _helper = new AudioFileHelper(_testAudioFileName); }