Skip to content

Commit f435705

Browse files
authored
Color padding in snapshot testing images (#275)
As discussed in #274. Fixes #274.
1 parent 43ba11d commit f435705

36 files changed

+84
-67
lines changed

parley/src/tests/utils/cursor_test.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,25 @@ impl CursorTest {
184184
// without visual cursors and with a warning that the text may not be accurate.
185185

186186
let bg_color_expected = Color::from_rgba8(255, 255, 255, 255);
187+
let padding_color_expected = Color::from_rgba8(166, 200, 255, 255);
187188
let cursor_color_expected = Color::from_rgba8(0, 255, 0, 255);
188189
let selection_color_expected = Color::from_rgba8(0, 255, 0, 200);
189190
let bg_color_actual = Color::from_rgba8(230, 230, 230, 255);
191+
let padding_color_actual = Color::from_rgba8(166, 255, 240, 255);
190192
let cursor_color_actual = Color::from_rgba8(255, 0, 0, 255);
191193
let selection_color_actual = Color::from_rgba8(255, 0, 0, 200);
192194

193195
let rendering_config_expected = RenderingConfig {
194196
background_color: bg_color_expected,
197+
padding_color: padding_color_expected,
195198
inline_box_color: bg_color_expected,
196199
cursor_color: cursor_color_expected,
197200
selection_color: selection_color_expected,
198201
size: None,
199202
};
200203
let rendering_config_actual = RenderingConfig {
201204
background_color: bg_color_actual,
205+
padding_color: padding_color_actual,
202206
inline_box_color: bg_color_actual,
203207
cursor_color: cursor_color_actual,
204208
selection_color: selection_color_actual,
@@ -351,11 +355,13 @@ impl CursorTest {
351355
#[allow(dead_code)]
352356
pub(crate) fn render_cursor(&self, cursor: Cursor) {
353357
let bg_color_cursor = Color::from_rgba8(255, 255, 255, 255);
358+
let padding_color_cursor = Color::from_rgba8(166, 200, 255, 255);
354359
let cursor_color_cursor = Color::from_rgba8(0, 255, 0, 255);
355360
let selection_color_cursor = Color::from_rgba8(0, 255, 0, 200);
356361

357362
let rendering_config_cursor = RenderingConfig {
358363
background_color: bg_color_cursor,
364+
padding_color: padding_color_cursor,
359365
inline_box_color: bg_color_cursor,
360366
cursor_color: cursor_color_cursor,
361367
selection_color: selection_color_cursor,

parley/src/tests/utils/env.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ impl TestEnv {
148148
text_color: Color::BLACK,
149149
rendering_config: RenderingConfig {
150150
background_color: Color::WHITE,
151+
padding_color: Color::from_rgba8(166, 200, 255, 255),
151152
cursor_color: Color::from_rgba8(255, 0, 0, 255),
152153
selection_color: Color::from_rgba8(196, 196, 0, 255),
153154
inline_box_color: Color::BLACK,

parley/src/tests/utils/renderer.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ impl Default for ColorBrush {
3232

3333
pub(crate) struct RenderingConfig {
3434
pub background_color: Color,
35+
pub padding_color: Color,
3536
pub inline_box_color: Color,
3637
pub cursor_color: Color,
3738
pub selection_color: Color,
@@ -73,10 +74,19 @@ pub(crate) fn render_layout(
7374

7475
let mut img = Pixmap::new(padded_width, padded_height).unwrap();
7576

76-
img.fill(config.background_color);
77+
img.fill(config.padding_color);
7778

7879
let mut pen = TinySkiaPen::new(img.as_mut());
7980

81+
draw_rect(
82+
&mut pen,
83+
fpadding,
84+
fpadding,
85+
width as f32,
86+
height as f32,
87+
config.background_color,
88+
);
89+
8090
for rect in selection_rects {
8191
draw_rect(
8292
&mut pen,
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)