feat: adiciona funcionalidade de remoção de faixas externas e atualiza o layout da UI

This commit is contained in:
2026-02-28 14:48:02 -03:00
parent 4aa7cf2dd4
commit 02c6d8ede2
9 changed files with 401 additions and 138 deletions
+1
View File
@@ -5,4 +5,5 @@ pub mod edit_existing_track_sync;
pub mod export_track;
pub mod generate_output;
pub mod load_media_info;
pub mod remove_track;
pub mod set_track_language;
+54
View File
@@ -0,0 +1,54 @@
use crate::domain::entities::Project;
use crate::domain::value_objects::TrackId;
use anyhow::{Result, anyhow};
/// Remove uma faixa externa do projeto pelo seu TrackId.
pub struct RemoveTrack;
impl RemoveTrack {
pub fn execute(project: &mut Project, id: TrackId) -> Result<()> {
if project.remove_track(id) {
Ok(())
} else {
Err(anyhow!("Faixa com id {:?} não encontrada.", id))
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::domain::entities::{AudioTrack, MkvOutput, Project, Track, VideoFile};
use crate::domain::value_objects::{FilePath, SyncOffset, TrackId, TrackLanguage};
fn make_project() -> Project {
Project::new(
VideoFile::new(FilePath::from("input.mkv")),
MkvOutput::new(FilePath::from("output.mkv")),
)
.unwrap()
}
#[test]
fn remove_faixa_existente() {
let mut project = make_project();
let id = project.next_track_id();
project.tracks.push(Track::Audio(AudioTrack::new(
id,
FilePath::from("audio.aac"),
SyncOffset::from_ms(0),
TrackLanguage::new("por").unwrap(),
)));
assert_eq!(project.tracks.len(), 1);
RemoveTrack::execute(&mut project, id).unwrap();
assert!(project.tracks.is_empty());
}
#[test]
fn erro_se_id_inexistente() {
let mut project = make_project();
let result = RemoveTrack::execute(&mut project, TrackId::new(99));
assert!(result.is_err());
}
}