rect: safer construction
This commit is contained in:
parent
411af0ea18
commit
a1dfc473a2
33 changed files with 245 additions and 159 deletions
|
|
@ -16,7 +16,10 @@ use {
|
|||
Axis, Direction,
|
||||
input::{InputDevice, Seat},
|
||||
keyboard::{Keymap, ModifiedKeySym},
|
||||
theme::{BarPosition, sized::BAR_SEPARATOR_WIDTH},
|
||||
theme::{
|
||||
BarPosition,
|
||||
sized::{BAR_SEPARATOR_WIDTH, Resizable},
|
||||
},
|
||||
video::{Connector, Transform},
|
||||
},
|
||||
std::{cell::Cell, ops::Deref, ptr, rc::Rc, time::Duration},
|
||||
|
|
@ -303,11 +306,12 @@ impl TestConfig {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn set_size(&self, sized: Resizable, size: i32) -> TestResult {
|
||||
self.send(ClientMessage::SetSize { sized, size })
|
||||
}
|
||||
|
||||
pub fn set_bar_separator_width(&self, width: i32) -> TestResult {
|
||||
self.send(ClientMessage::SetSize {
|
||||
sized: BAR_SEPARATOR_WIDTH,
|
||||
size: width,
|
||||
})
|
||||
self.set_size(BAR_SEPARATOR_WIDTH, width)
|
||||
}
|
||||
|
||||
pub fn set_bar_position(&self, position: BarPosition) -> TestResult {
|
||||
|
|
@ -323,6 +327,10 @@ impl TestConfig {
|
|||
get_response!(reply, GetShowBar { show });
|
||||
Ok(show)
|
||||
}
|
||||
|
||||
pub fn set_show_titles(&self, show: bool) -> TestResult {
|
||||
self.send(ClientMessage::SetShowTitles { show })
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TestConfig {
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ mod t0049_surface_damage_backend;
|
|||
mod t0050_fifo;
|
||||
mod t0051_pointer_warp;
|
||||
mod t0052_bar;
|
||||
mod t0053_theme;
|
||||
|
||||
pub trait TestCase: Sync {
|
||||
fn name(&self) -> &'static str;
|
||||
|
|
@ -154,5 +155,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
|
|||
t0050_fifo,
|
||||
t0051_pointer_warp,
|
||||
t0052_bar,
|
||||
t0053_theme,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
48
src/it/tests/t0053_theme.rs
Normal file
48
src/it/tests/t0053_theme.rs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
use {
|
||||
crate::it::{test_error::TestError, testrun::TestRun},
|
||||
jay_config::theme::sized::{BORDER_WIDTH, TITLE_HEIGHT},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
testcase!();
|
||||
|
||||
async fn test(run: Rc<TestRun>) -> Result<(), TestError> {
|
||||
let setup = run.create_default_setup().await?;
|
||||
let client = run.create_client().await?;
|
||||
let win = client.create_window().await?;
|
||||
win.map().await?;
|
||||
client.sync().await;
|
||||
|
||||
// Make it floating
|
||||
run.cfg.set_floating(setup.seat.id(), true)?;
|
||||
run.sync().await;
|
||||
|
||||
let float_node = run
|
||||
.state
|
||||
.root
|
||||
.stacked
|
||||
.iter()
|
||||
.find_map(|n| Rc::clone(&n).node_into_float())
|
||||
.unwrap();
|
||||
|
||||
let pos = float_node.position.get();
|
||||
|
||||
// 1. Huge borders: Ensure renderer doesn't crash when borders are larger than window
|
||||
let huge_bw = pos.width() / 2 + 10;
|
||||
run.cfg.set_size(BORDER_WIDTH, huge_bw)?;
|
||||
run.sync().await;
|
||||
let _ = client.take_screenshot(false).await?;
|
||||
|
||||
// Reset border
|
||||
run.cfg.set_size(BORDER_WIDTH, 5)?;
|
||||
run.sync().await;
|
||||
|
||||
// 2. Huge title height: Ensure renderer doesn't crash when title is larger than window
|
||||
let huge_th = pos.height() + 10;
|
||||
run.cfg.set_size(TITLE_HEIGHT, huge_th)?;
|
||||
run.cfg.set_show_titles(true)?;
|
||||
run.sync().await;
|
||||
let _ = client.take_screenshot(false).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue