2018-11-04 19:16:10 +00:00
|
|
|
use tui::backend::TestBackend;
|
|
|
|
use tui::buffer::Buffer;
|
|
|
|
use tui::layout::Rect;
|
|
|
|
use tui::style::{Color, Style};
|
2019-12-15 20:38:18 +00:00
|
|
|
use tui::widgets::{Block, Borders};
|
2018-11-04 19:16:10 +00:00
|
|
|
use tui::Terminal;
|
|
|
|
|
|
|
|
#[test]
|
2020-05-21 18:42:34 +00:00
|
|
|
fn widgets_block_renders() {
|
2018-11-04 19:16:10 +00:00
|
|
|
let backend = TestBackend::new(10, 10);
|
|
|
|
let mut terminal = Terminal::new(backend).unwrap();
|
|
|
|
terminal
|
2020-06-15 20:57:23 +00:00
|
|
|
.draw(|f| {
|
2019-12-15 20:38:18 +00:00
|
|
|
let block = Block::default()
|
2018-11-04 19:16:10 +00:00
|
|
|
.title("Title")
|
|
|
|
.borders(Borders::ALL)
|
2019-12-15 20:38:18 +00:00
|
|
|
.title_style(Style::default().fg(Color::LightBlue));
|
|
|
|
f.render_widget(
|
|
|
|
block,
|
|
|
|
Rect {
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
width: 8,
|
|
|
|
height: 8,
|
|
|
|
},
|
|
|
|
);
|
2018-12-07 15:17:33 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2018-11-04 19:16:10 +00:00
|
|
|
let mut expected = Buffer::with_lines(vec![
|
|
|
|
"┌Title─┐ ",
|
|
|
|
"│ │ ",
|
|
|
|
"│ │ ",
|
|
|
|
"│ │ ",
|
|
|
|
"│ │ ",
|
|
|
|
"│ │ ",
|
|
|
|
"│ │ ",
|
|
|
|
"└──────┘ ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
]);
|
|
|
|
for x in 1..=5 {
|
|
|
|
expected.get_mut(x, 0).set_fg(Color::LightBlue);
|
|
|
|
}
|
2020-05-21 18:17:55 +00:00
|
|
|
terminal.backend().assert_buffer(&expected);
|
2018-11-04 19:16:10 +00:00
|
|
|
}
|