theme: add bar-separator-width setting
This commit is contained in:
parent
f5ed6f8fac
commit
a6e629dd2f
16 changed files with 163 additions and 31 deletions
|
|
@ -16,6 +16,7 @@ use {
|
|||
Axis, Direction,
|
||||
input::{InputDevice, Seat},
|
||||
keyboard::{Keymap, ModifiedKeySym},
|
||||
theme::{BarPosition, sized::BAR_SEPARATOR_WIDTH},
|
||||
video::{Connector, Transform},
|
||||
},
|
||||
std::{cell::Cell, ops::Deref, ptr, rc::Rc, time::Duration},
|
||||
|
|
@ -301,6 +302,27 @@ impl TestConfig {
|
|||
transform,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_bar_separator_width(&self, width: i32) -> TestResult {
|
||||
self.send(ClientMessage::SetSize {
|
||||
sized: BAR_SEPARATOR_WIDTH,
|
||||
size: width,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_bar_position(&self, position: BarPosition) -> TestResult {
|
||||
self.send(ClientMessage::SetBarPosition { position })
|
||||
}
|
||||
|
||||
pub fn set_show_bar(&self, show: bool) -> TestResult {
|
||||
self.send(ClientMessage::SetShowBar { show })
|
||||
}
|
||||
|
||||
pub fn get_show_bar(&self) -> Result<bool, TestError> {
|
||||
let reply = self.send_with_reply(ClientMessage::GetShowBar)?;
|
||||
get_response!(reply, GetShowBar { show });
|
||||
Ok(show)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TestConfig {
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ mod t0048_frame_callback;
|
|||
mod t0049_surface_damage_backend;
|
||||
mod t0050_fifo;
|
||||
mod t0051_pointer_warp;
|
||||
mod t0052_bar;
|
||||
|
||||
pub trait TestCase: Sync {
|
||||
fn name(&self) -> &'static str;
|
||||
|
|
@ -152,5 +153,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
|
|||
t0049_surface_damage_backend,
|
||||
t0050_fifo,
|
||||
t0051_pointer_warp,
|
||||
t0052_bar,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
67
src/it/tests/t0052_bar.rs
Normal file
67
src/it/tests/t0052_bar.rs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{test_error::TestError, testrun::TestRun},
|
||||
tree::OutputNode,
|
||||
},
|
||||
jay_config::theme::BarPosition,
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
testcase!();
|
||||
|
||||
async fn test(run: Rc<TestRun>) -> Result<(), TestError> {
|
||||
let setup = run.create_default_setup().await?;
|
||||
|
||||
test_bar(&run, &setup.output, 0).await?;
|
||||
test_bar(&run, &setup.output, 1).await?;
|
||||
test_bar(&run, &setup.output, 20).await?;
|
||||
test_bar(&run, &setup.output, 100).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn test_bar(
|
||||
run: &TestRun,
|
||||
output: &OutputNode,
|
||||
separator_width: i32,
|
||||
) -> Result<(), TestError> {
|
||||
let output_rect = output.global.pos.get();
|
||||
|
||||
run.cfg.set_bar_separator_width(separator_width)?;
|
||||
run.cfg.set_bar_position(BarPosition::Top)?;
|
||||
run.sync().await;
|
||||
|
||||
let bar_height = run.state.theme.sizes.bar_height();
|
||||
tassert_eq!(run.state.theme.sizes.bar_separator_width(), separator_width);
|
||||
|
||||
let bar_total_height = bar_height + separator_width;
|
||||
let bar_rect = output.bar_rect_with_separator.get();
|
||||
let ws_rect = output.workspace_rect.get();
|
||||
|
||||
tassert_eq!(bar_rect.y1(), output_rect.y1());
|
||||
tassert_eq!(bar_rect.height(), bar_total_height);
|
||||
tassert_eq!(ws_rect.y1(), output_rect.y1() + bar_total_height);
|
||||
tassert_eq!(ws_rect.height(), output_rect.height() - bar_total_height);
|
||||
|
||||
run.cfg.set_bar_position(BarPosition::Bottom)?;
|
||||
run.sync().await;
|
||||
|
||||
let bar_rect = output.bar_rect_with_separator.get();
|
||||
let ws_rect = output.workspace_rect.get();
|
||||
tassert_eq!(bar_rect.y2(), output_rect.y2());
|
||||
tassert_eq!(bar_rect.height(), bar_total_height);
|
||||
tassert_eq!(ws_rect.y2(), output_rect.y2() - bar_total_height);
|
||||
tassert_eq!(ws_rect.height(), output_rect.height() - bar_total_height);
|
||||
|
||||
run.cfg.set_show_bar(false)?;
|
||||
run.sync().await;
|
||||
|
||||
tassert_eq!(run.cfg.get_show_bar()?, false);
|
||||
tassert_eq!(output.workspace_rect.get(), output_rect);
|
||||
tassert_eq!(output.bar_rect_with_separator.get().is_empty(), true);
|
||||
|
||||
run.cfg.set_show_bar(true)?;
|
||||
run.sync().await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue