feat: rename targets from the fader editor
Add a Name row and cursor-aware rename modal for application and group faders. Persist only the target display label while retaining stable IDs, selectors, group membership, bindings, and layout; keep backend-owned output labels unchanged. Tests: cargo fmt --all; cargo check --workspace --all-targets --all-features; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo test -p tui; cargo test -p fader-config --test editor; targeted fader_master editor test; cargo test --workspace --doc --all-features; cargo build --workspace --release --all-features. Full workspace tests stop at the pre-existing edited examples/profiles/arch-pipewire.toml fixture mismatch.
This commit is contained in:
parent
1863f82f15
commit
34c738847f
|
|
@ -111,7 +111,7 @@ they do not represent a live hardware session.
|
|||
|
||||
Use `Tab` to open Config, select Mixer layout and use Left/Right to switch its
|
||||
orientation, `T` to cycle the theme, and `Q` to open the quit confirmation.
|
||||
Fader editing exposes capture rules, group membership, separate
|
||||
Fader editing exposes the application/group display name, capture rules, group membership, separate
|
||||
controller/Learn/Unlearn actions for volume and mute, size, and visibility.
|
||||
Add opens a chooser for a new application fader, empty group, or separator.
|
||||
New faders and groups open directly in the editor and remain visible as offline
|
||||
|
|
|
|||
|
|
@ -549,6 +549,8 @@ before distributing remaining space evenly among visible Fill separators;
|
|||
expansion never evicts a fader or wraps the horizontal row. Editing a fader
|
||||
presents domain fields rather than a serialized command:
|
||||
|
||||
- **Name:** rename the application or group display label while retaining its
|
||||
stable target and fader IDs. Default-output labels remain backend-owned.
|
||||
- **Capture:** application selector field, exact/regex mode, and pattern. Pattern
|
||||
values open in a cursor-aware modal with insertion, Backspace, Delete,
|
||||
Home/End, accept, and cancel controls; group faders instead present a member
|
||||
|
|
|
|||
|
|
@ -392,6 +392,22 @@ pickup_tolerance = 0.02
|
|||
})
|
||||
}
|
||||
|
||||
/// Changes one group's display label without changing its members or mode.
|
||||
pub fn set_group_label(&mut self, id: &str, label: &str) -> Result<(), ConfigError> {
|
||||
self.transaction(|document| {
|
||||
let table = find_table_mut(document, "groups", id)?;
|
||||
let existing = table
|
||||
.get_mut("label")
|
||||
.and_then(Item::as_value_mut)
|
||||
.ok_or_else(|| ConfigError::validation("groups.label", "missing string label"))?;
|
||||
let decor = existing.decor().clone();
|
||||
let mut replacement = Value::from(label);
|
||||
*replacement.decor_mut() = decor;
|
||||
*existing = replacement;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
/// Removes an unreferenced group.
|
||||
pub fn remove_group(&mut self, id: &str) -> Result<(), ConfigError> {
|
||||
self.remove_table("groups", id)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,21 @@ fn removing_a_surface_clears_its_bindings_and_default_controller_atomically() {
|
|||
assert_eq!(profile.default_controller(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn target_labels_can_be_renamed_without_changing_routing() {
|
||||
let mut draft = ProfileDocument::parse(PROFILE).unwrap();
|
||||
|
||||
draft.set_application_label("music", "Listening").unwrap();
|
||||
draft.set_group_label("media", "Entertainment").unwrap();
|
||||
|
||||
let profile = draft.preview().unwrap();
|
||||
assert_eq!(profile.applications()[0].label(), "Listening");
|
||||
assert_eq!(profile.groups()[0].label(), "Entertainment");
|
||||
assert_eq!(profile.groups()[0].members(), &["music", "browser"]);
|
||||
assert_eq!(profile.faders()[0].target_id(), "media");
|
||||
assert_eq!(profile.bindings().len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mixer_objects_are_created_and_removed_as_atomic_valid_units() {
|
||||
let mut draft = ProfileDocument::empty("default").unwrap();
|
||||
|
|
|
|||
|
|
@ -189,9 +189,12 @@ or separator. A new fader or group opens its guided editor immediately; its
|
|||
placeholder capture or empty membership keeps it offline until configured.
|
||||
Press `E` to edit the selected fader or separator, and `D` to delete it after
|
||||
confirmation. Deleting a fader also removes its bindings and an application or
|
||||
group target that is not shared or referenced elsewhere. Use Up/Down or Tab to
|
||||
choose popup fields, Left/Right to change options, Enter to accept, and Escape
|
||||
to cancel. Config → Save persists and activates the draft.
|
||||
group target that is not shared or referenced elsewhere. The fader editor's
|
||||
Name row renames an application or group label without changing stable IDs,
|
||||
capture, membership, bindings, or layout; default-output labels come from the
|
||||
audio backend. Use Up/Down or Tab to choose popup fields, Left/Right to change
|
||||
options, Enter to accept, and Escape to cancel. Config → Save persists and
|
||||
activates the draft.
|
||||
|
||||
Separator `size` is `slim`, `standard`, `thick`, or `fill`; `decoration`
|
||||
is `plain` (label only), `line`, `double`, or `box`. Existing separators
|
||||
|
|
|
|||
|
|
@ -95,6 +95,19 @@ impl ConfigurationEditor {
|
|||
.document
|
||||
.add_group_fader(&group_id, &label, &fader_id, position)?,
|
||||
ConfigurationEdit::RemoveMixerFader { id } => self.document.remove_mixer_fader(&id)?,
|
||||
ConfigurationEdit::SetTargetLabel { target, label } => match target.kind {
|
||||
MixerObjectKind::Application => {
|
||||
self.document.set_application_label(&target.id, &label)?
|
||||
}
|
||||
MixerObjectKind::Group => self.document.set_group_label(&target.id, &label)?,
|
||||
MixerObjectKind::Output => {
|
||||
return Err(ConfigError::Validation {
|
||||
path: "faders.target".to_owned(),
|
||||
message: "the backend-owned output label cannot be renamed".to_owned(),
|
||||
}
|
||||
.into());
|
||||
}
|
||||
},
|
||||
ConfigurationEdit::AddSurface {
|
||||
id,
|
||||
label,
|
||||
|
|
@ -505,6 +518,46 @@ mod tests {
|
|||
assert_eq!(profile.default_controller(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn target_label_edits_preserve_stable_routing_ids() {
|
||||
let root = tempdir().unwrap();
|
||||
let path = root.path().join("desktop.toml");
|
||||
let document = ProfileDocument::parse(PROFILE).unwrap();
|
||||
fs::write(&path, document.source()).unwrap();
|
||||
let mut editor = ConfigurationEditor::new(document, path);
|
||||
|
||||
let profile = editor
|
||||
.apply(
|
||||
0,
|
||||
ConfigurationEdit::SetTargetLabel {
|
||||
target: MixerObjectKey {
|
||||
kind: MixerObjectKind::Application,
|
||||
id: "music".into(),
|
||||
},
|
||||
label: "Listening".into(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(profile.applications()[0].id(), "music");
|
||||
assert_eq!(profile.applications()[0].label(), "Listening");
|
||||
|
||||
let profile = editor
|
||||
.apply(
|
||||
1,
|
||||
ConfigurationEdit::SetTargetLabel {
|
||||
target: MixerObjectKey {
|
||||
kind: MixerObjectKind::Group,
|
||||
id: "media".into(),
|
||||
},
|
||||
label: "Entertainment".into(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(profile.groups()[0].id(), "media");
|
||||
assert_eq!(profile.groups()[0].label(), "Entertainment");
|
||||
assert_eq!(profile.faders()[0].target_id(), "media");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mixer_object_edits_create_and_delete_complete_valid_units() {
|
||||
let root = tempdir().unwrap();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::io::{self, Read, Write};
|
|||
use serde::{Deserialize, Serialize, de::DeserializeOwned};
|
||||
use thiserror::Error;
|
||||
|
||||
pub const PROTOCOL_VERSION: u16 = 22;
|
||||
pub const PROTOCOL_VERSION: u16 = 23;
|
||||
pub const MAX_FRAME_BYTES: usize = 64 * 1024;
|
||||
|
||||
/// Kind of mixer object addressed by a client.
|
||||
|
|
@ -95,6 +95,10 @@ pub enum ConfigurationEdit {
|
|||
RemoveMixerFader {
|
||||
id: String,
|
||||
},
|
||||
SetTargetLabel {
|
||||
target: MixerObjectKey,
|
||||
label: String,
|
||||
},
|
||||
AddSurface {
|
||||
id: String,
|
||||
label: String,
|
||||
|
|
|
|||
|
|
@ -385,6 +385,10 @@ fn configuration_edit(edit: TuiConfigurationEdit) -> crate::ipc::ConfigurationEd
|
|||
position,
|
||||
},
|
||||
TuiConfigurationEdit::RemoveMixerFader { id } => IpcEdit::RemoveMixerFader { id },
|
||||
TuiConfigurationEdit::SetTargetLabel { target, label } => IpcEdit::SetTargetLabel {
|
||||
target: key(target),
|
||||
label,
|
||||
},
|
||||
TuiConfigurationEdit::AddSurface {
|
||||
id,
|
||||
label,
|
||||
|
|
|
|||
3
task.md
3
task.md
|
|
@ -447,6 +447,9 @@ Dependencies: M8, M2, M1.
|
|||
bindings keep their selected surface. A new mute assignment inherits feedback
|
||||
values only from one unambiguous same-surface, same-message-kind convention
|
||||
and otherwise leaves device-specific feedback unset.
|
||||
Application and group faders expose a Name row with a cursor-aware rename
|
||||
popup. Renaming changes only the target display label; stable IDs, selectors,
|
||||
membership, bindings, and layout remain intact. Output labels stay backend-owned.
|
||||
- [x] **M9.6 Single-screen configuration workflow:** remove the normalized
|
||||
Config table browser once all its operations are reachable from the mixer,
|
||||
keep Save and draft/durable status visible, and expose hidden-item
|
||||
|
|
|
|||
226
tui/src/lib.rs
226
tui/src/lib.rs
|
|
@ -369,6 +369,10 @@ pub enum ConfigurationEdit {
|
|||
RemoveMixerFader {
|
||||
id: String,
|
||||
},
|
||||
SetTargetLabel {
|
||||
target: MixerObjectId,
|
||||
label: String,
|
||||
},
|
||||
AddSurface {
|
||||
id: String,
|
||||
label: String,
|
||||
|
|
@ -1000,6 +1004,35 @@ fn apply_optimistic_configuration_edit(snapshot: &mut MixerSnapshot, edit: &Conf
|
|||
}
|
||||
snapshot.configuration.dirty = true;
|
||||
}
|
||||
ConfigurationEdit::SetTargetLabel { target, label } => {
|
||||
match target.kind {
|
||||
MixerObjectKind::Application => {
|
||||
if let Some(application) = snapshot
|
||||
.configuration
|
||||
.applications
|
||||
.iter_mut()
|
||||
.find(|application| application.id == target.id)
|
||||
{
|
||||
application.label.clone_from(label);
|
||||
}
|
||||
}
|
||||
MixerObjectKind::Group => {
|
||||
if let Some(group) = snapshot
|
||||
.configuration
|
||||
.groups
|
||||
.iter_mut()
|
||||
.find(|group| group.id == target.id)
|
||||
{
|
||||
group.label.clone_from(label);
|
||||
}
|
||||
}
|
||||
MixerObjectKind::Output => return,
|
||||
}
|
||||
if let Some(item) = snapshot.items.iter_mut().find(|item| item.id == *target) {
|
||||
item.label.clone_from(label);
|
||||
}
|
||||
snapshot.configuration.dirty = true;
|
||||
}
|
||||
ConfigurationEdit::MoveLayoutEntry { id, position } => {
|
||||
let Some(index) = snapshot
|
||||
.configuration
|
||||
|
|
@ -1226,6 +1259,7 @@ pub struct LiveTui<C> {
|
|||
fader_editor: Option<FaderEditor>,
|
||||
capture_editor: Option<CaptureEditor>,
|
||||
pattern_editor: Option<PatternEditor>,
|
||||
rename_editor: Option<RenameEditor>,
|
||||
controller_picker: Option<ControllerPicker>,
|
||||
group_member_picker: Option<GroupMemberPicker>,
|
||||
hidden_fader_picker: Option<HiddenFaderPicker>,
|
||||
|
|
@ -1287,6 +1321,13 @@ struct PatternEditor {
|
|||
cursor: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
struct RenameEditor {
|
||||
target: MixerObjectId,
|
||||
value: String,
|
||||
cursor: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
struct ControllerPicker {
|
||||
fader: String,
|
||||
|
|
@ -1362,6 +1403,10 @@ struct DeviceDeleteConfirmation {
|
|||
}
|
||||
|
||||
enum FaderEditorRow {
|
||||
Name {
|
||||
target: MixerObjectId,
|
||||
label: String,
|
||||
},
|
||||
Capture {
|
||||
application: String,
|
||||
selector: usize,
|
||||
|
|
@ -1555,10 +1600,7 @@ fn add_draft_mixer_items(snapshot: &mut MixerSnapshot) {
|
|||
.map(|fader| fader.target.clone())
|
||||
.collect::<Vec<_>>();
|
||||
for target in targets {
|
||||
if snapshot.items.iter().any(|item| item.id == target) {
|
||||
continue;
|
||||
}
|
||||
let label = match target.kind {
|
||||
let configured_label = match target.kind {
|
||||
MixerObjectKind::Application => snapshot
|
||||
.configuration
|
||||
.applications
|
||||
|
|
@ -1572,8 +1614,14 @@ fn add_draft_mixer_items(snapshot: &mut MixerSnapshot) {
|
|||
.find(|group| group.id == target.id)
|
||||
.map(|group| group.label.clone()),
|
||||
MixerObjectKind::Output => None,
|
||||
};
|
||||
if let Some(item) = snapshot.items.iter_mut().find(|item| item.id == target) {
|
||||
if let Some(label) = &configured_label {
|
||||
item.label.clone_from(label);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
.unwrap_or_else(|| target.id.clone());
|
||||
let label = configured_label.unwrap_or_else(|| target.id.clone());
|
||||
snapshot.items.push(MixerItem {
|
||||
id: target,
|
||||
label,
|
||||
|
|
@ -1657,6 +1705,7 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
fader_editor: None,
|
||||
capture_editor: None,
|
||||
pattern_editor: None,
|
||||
rename_editor: None,
|
||||
controller_picker: None,
|
||||
group_member_picker: None,
|
||||
hidden_fader_picker: None,
|
||||
|
|
@ -1835,6 +1884,10 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
self.handle_pattern_key(key_event.code);
|
||||
return;
|
||||
}
|
||||
if self.rename_editor.is_some() {
|
||||
self.handle_rename_key(key_event.code);
|
||||
return;
|
||||
}
|
||||
if self.capture_editor.is_some() {
|
||||
self.handle_capture_key(key_event.code);
|
||||
return;
|
||||
|
|
@ -2654,6 +2707,10 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
.iter()
|
||||
.find(|application| application.id == fader.target.id)
|
||||
{
|
||||
rows.push(FaderEditorRow::Name {
|
||||
target: fader.target.clone(),
|
||||
label: application.label.clone(),
|
||||
});
|
||||
rows.extend(application.selectors.iter().enumerate().map(
|
||||
|(selector, capture)| FaderEditorRow::Capture {
|
||||
application: application.id.clone(),
|
||||
|
|
@ -2673,6 +2730,10 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
.iter()
|
||||
.find(|group| group.id == fader.target.id)
|
||||
{
|
||||
rows.push(FaderEditorRow::Name {
|
||||
target: fader.target.clone(),
|
||||
label: group.label.clone(),
|
||||
});
|
||||
let choices = self.group_member_choices(&group.id);
|
||||
rows.push(FaderEditorRow::GroupMembers {
|
||||
group: group.id.clone(),
|
||||
|
|
@ -2828,6 +2889,13 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
return;
|
||||
};
|
||||
match row {
|
||||
FaderEditorRow::Name { target, label } => {
|
||||
self.rename_editor = Some(RenameEditor {
|
||||
target,
|
||||
cursor: label.chars().count(),
|
||||
value: label,
|
||||
});
|
||||
}
|
||||
FaderEditorRow::Capture {
|
||||
application,
|
||||
selector,
|
||||
|
|
@ -3047,6 +3115,64 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_rename_key(&mut self, code: KeyCode) {
|
||||
if code == KeyCode::Esc {
|
||||
self.rename_editor = None;
|
||||
return;
|
||||
}
|
||||
let Some(editor) = &mut self.rename_editor else {
|
||||
return;
|
||||
};
|
||||
let character_count = editor.value.chars().count();
|
||||
match code {
|
||||
KeyCode::Left => editor.cursor = editor.cursor.saturating_sub(1),
|
||||
KeyCode::Right => editor.cursor = (editor.cursor + 1).min(character_count),
|
||||
KeyCode::Home => editor.cursor = 0,
|
||||
KeyCode::End => editor.cursor = character_count,
|
||||
KeyCode::Backspace if editor.cursor > 0 => {
|
||||
let previous = editor.cursor - 1;
|
||||
remove_character(&mut editor.value, previous);
|
||||
editor.cursor = previous;
|
||||
}
|
||||
KeyCode::Delete if editor.cursor < character_count => {
|
||||
remove_character(&mut editor.value, editor.cursor);
|
||||
}
|
||||
KeyCode::Char(character) => {
|
||||
let byte = character_byte_index(&editor.value, editor.cursor);
|
||||
editor.value.insert(byte, character);
|
||||
editor.cursor += 1;
|
||||
}
|
||||
KeyCode::Enter => self.submit_rename_editor(),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn submit_rename_editor(&mut self) {
|
||||
let Some(editor) = &self.rename_editor else {
|
||||
return;
|
||||
};
|
||||
let label = editor.value.trim();
|
||||
if label.is_empty() {
|
||||
self.client_error = Some("a fader name is required".to_owned());
|
||||
return;
|
||||
}
|
||||
let edit = ConfigurationEdit::SetTargetLabel {
|
||||
target: editor.target.clone(),
|
||||
label: label.to_owned(),
|
||||
};
|
||||
match self
|
||||
.client
|
||||
.edit_configuration(edit, self.snapshot.configuration.revision)
|
||||
{
|
||||
Ok(snapshot) => {
|
||||
self.rename_editor = None;
|
||||
self.replace_snapshot(snapshot);
|
||||
self.client_error = None;
|
||||
}
|
||||
Err(error) => self.client_error = Some(error.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
fn submit_capture_editor(&mut self) {
|
||||
let Some(editor) = &self.capture_editor else {
|
||||
return;
|
||||
|
|
@ -3413,6 +3539,9 @@ impl<C: MixerClient> Widget for &LiveTui<C> {
|
|||
if self.fader_editor.is_some() {
|
||||
self.render_fader_editor(area, buf);
|
||||
}
|
||||
if self.rename_editor.is_some() {
|
||||
self.render_rename_editor(area, buf);
|
||||
}
|
||||
if self.capture_editor.is_some() {
|
||||
self.render_capture_editor(area, buf);
|
||||
}
|
||||
|
|
@ -3907,6 +4036,9 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
.map(|(index, row)| {
|
||||
let marker = if index == editor.selected { "▶" } else { " " };
|
||||
let text = match row {
|
||||
FaderEditorRow::Name { label, .. } => {
|
||||
format!("{marker} Name {label} [Enter to rename]")
|
||||
}
|
||||
FaderEditorRow::Capture {
|
||||
selector,
|
||||
field,
|
||||
|
|
@ -3984,6 +4116,48 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
.render(popup, buf);
|
||||
}
|
||||
|
||||
fn render_rename_editor(&self, area: Rect, buf: &mut Buffer) {
|
||||
let Some(editor) = &self.rename_editor else {
|
||||
return;
|
||||
};
|
||||
let theme = self.theme.palette();
|
||||
let popup = centered_rect(area, 72, 7);
|
||||
let characters = editor.value.chars().collect::<Vec<_>>();
|
||||
let cursor = editor.cursor.min(characters.len());
|
||||
let capacity = usize::from(popup.width.saturating_sub(4)).saturating_sub(1);
|
||||
let mut start = cursor.saturating_sub(capacity / 2);
|
||||
if characters.len().saturating_sub(start) < capacity {
|
||||
start = characters.len().saturating_sub(capacity);
|
||||
}
|
||||
let end = start.saturating_add(capacity).min(characters.len());
|
||||
let before = characters[start..cursor].iter().collect::<String>();
|
||||
let after = characters[cursor..end].iter().collect::<String>();
|
||||
|
||||
Clear.render(popup, buf);
|
||||
Paragraph::new(Text::from(vec![
|
||||
Line::from("Fader name"),
|
||||
Line::from(vec![
|
||||
Span::raw(before),
|
||||
"▏".fg(theme.accent).bold(),
|
||||
Span::raw(after),
|
||||
])
|
||||
.style(Style::default().fg(theme.foreground)),
|
||||
Line::from("The stable fader and target IDs are unchanged.").fg(theme.muted),
|
||||
]))
|
||||
.block(
|
||||
Block::bordered()
|
||||
.title(" Rename fader ".fg(theme.accent).bold())
|
||||
.title_bottom(
|
||||
" ←→/Home/End move · Backspace/Delete edit · Enter apply · Esc cancel "
|
||||
.fg(theme.muted),
|
||||
)
|
||||
.border_set(border::DOUBLE)
|
||||
.border_style(Style::default().fg(theme.accent))
|
||||
.style(Style::default().bg(theme.background)),
|
||||
)
|
||||
.render(popup, buf);
|
||||
}
|
||||
|
||||
fn render_group_member_picker(&self, area: Rect, buf: &mut Buffer) {
|
||||
let Some(picker) = &self.group_member_picker else {
|
||||
return;
|
||||
|
|
@ -5073,6 +5247,7 @@ mod tests {
|
|||
ConfigurationEdit::AddApplicationFader { .. }
|
||||
| ConfigurationEdit::AddGroupFader { .. }
|
||||
| ConfigurationEdit::RemoveMixerFader { .. }
|
||||
| ConfigurationEdit::SetTargetLabel { .. }
|
||||
| ConfigurationEdit::AddSurface { .. }
|
||||
| ConfigurationEdit::RemoveSurface { .. } => {
|
||||
apply_optimistic_configuration_edit(&mut self.snapshot, &edit);
|
||||
|
|
@ -6291,6 +6466,7 @@ mod tests {
|
|||
.map(|cell| cell.symbol())
|
||||
.collect::<String>();
|
||||
assert!(rendered.contains("Edit fader: music-fader"));
|
||||
assert!(rendered.contains("Name Music"));
|
||||
assert!(rendered.contains("Capture 1"));
|
||||
assert!(rendered.contains("Volume controller"));
|
||||
assert!(rendered.contains("Learn volume MIDI"));
|
||||
|
|
@ -6302,6 +6478,27 @@ mod tests {
|
|||
assert!(rendered.contains("Size Standard"));
|
||||
assert!(rendered.contains("Visibility"));
|
||||
|
||||
app.handle_key_event(press(KeyCode::Enter));
|
||||
let mut rename_editor = Buffer::empty(area);
|
||||
(&app).render(area, &mut rename_editor);
|
||||
let rename_rendered = rename_editor
|
||||
.content
|
||||
.iter()
|
||||
.map(|cell| cell.symbol())
|
||||
.collect::<String>();
|
||||
assert!(rename_rendered.contains("Rename fader"));
|
||||
for character in " Player".chars() {
|
||||
app.handle_key_event(press(KeyCode::Char(character)));
|
||||
}
|
||||
app.handle_key_event(press(KeyCode::Enter));
|
||||
assert_eq!(app.snapshot.items[0].label, "Music Player");
|
||||
assert_eq!(app.snapshot.configuration.applications[0].id, "music");
|
||||
assert_eq!(
|
||||
app.snapshot.configuration.applications[0].label,
|
||||
"Music Player"
|
||||
);
|
||||
|
||||
app.handle_key_event(press(KeyCode::Down));
|
||||
app.handle_key_event(press(KeyCode::Enter));
|
||||
app.handle_key_event(press(KeyCode::Right));
|
||||
app.handle_key_event(press(KeyCode::Down));
|
||||
|
|
@ -6367,6 +6564,11 @@ mod tests {
|
|||
app.handle_key_event(press(KeyCode::Enter));
|
||||
|
||||
let edits = edits.lock().unwrap();
|
||||
assert!(edits.iter().any(|edit| matches!(
|
||||
edit,
|
||||
ConfigurationEdit::SetTargetLabel { target, label }
|
||||
if target.id == "music" && label == "Music Player"
|
||||
)));
|
||||
assert!(edits.iter().any(|edit| matches!(
|
||||
edit,
|
||||
ConfigurationEdit::SetApplicationSelector {
|
||||
|
|
@ -6427,11 +6629,11 @@ mod tests {
|
|||
app.handle_key_event(press(KeyCode::Char('e')));
|
||||
let rows = app.fader_editor_rows();
|
||||
assert!(matches!(
|
||||
&rows[0],
|
||||
&rows[1],
|
||||
FaderEditorRow::BindingController { value, .. }
|
||||
if value == "Default · Desk controller"
|
||||
));
|
||||
app.fader_editor.as_mut().unwrap().selected = 1;
|
||||
app.fader_editor.as_mut().unwrap().selected = 2;
|
||||
app.handle_key_event(press(KeyCode::Enter));
|
||||
|
||||
assert_eq!(
|
||||
|
|
@ -6509,9 +6711,11 @@ mod tests {
|
|||
.unwrap();
|
||||
|
||||
app.handle_key_event(press(KeyCode::Char('e')));
|
||||
for _ in 0..6 {
|
||||
app.handle_key_event(press(KeyCode::Down));
|
||||
}
|
||||
app.fader_editor.as_mut().unwrap().selected = app
|
||||
.fader_editor_rows()
|
||||
.iter()
|
||||
.position(|row| matches!(row, FaderEditorRow::Density { .. }))
|
||||
.unwrap();
|
||||
app.handle_key_event(press(KeyCode::Enter));
|
||||
assert!(edits.lock().unwrap().iter().any(|edit| matches!(
|
||||
edit,
|
||||
|
|
@ -6755,10 +6959,12 @@ mod tests {
|
|||
.map(|cell| cell.symbol())
|
||||
.collect::<String>();
|
||||
assert!(rendered.contains("Members 1 of 2 selected"));
|
||||
assert!(rendered.contains("Name Media"));
|
||||
assert!(!rendered.contains("Group member Music"));
|
||||
assert!(!rendered.contains("Group member Browser"));
|
||||
assert!(rendered.contains("Group mode Relative"));
|
||||
|
||||
app.handle_key_event(press(KeyCode::Down));
|
||||
app.handle_key_event(press(KeyCode::Enter));
|
||||
let mut popup_buffer = Buffer::empty(area);
|
||||
(&app).render(area, &mut popup_buffer);
|
||||
|
|
|
|||
Loading…
Reference in New Issue