Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color padding in snapshot testing images #275

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions parley/src/tests/utils/cursor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,25 @@ impl CursorTest {
// without visual cursors and with a warning that the text may not be accurate.

let bg_color_expected = Color::from_rgba8(255, 255, 255, 255);
let padding_color_expected = Color::from_rgba8(166, 200, 255, 255);
let cursor_color_expected = Color::from_rgba8(0, 255, 0, 255);
let selection_color_expected = Color::from_rgba8(0, 255, 0, 200);
let bg_color_actual = Color::from_rgba8(230, 230, 230, 255);
let padding_color_actual = Color::from_rgba8(166, 255, 240, 255);
let cursor_color_actual = Color::from_rgba8(255, 0, 0, 255);
let selection_color_actual = Color::from_rgba8(255, 0, 0, 200);

let rendering_config_expected = RenderingConfig {
background_color: bg_color_expected,
padding_color: padding_color_expected,
inline_box_color: bg_color_expected,
cursor_color: cursor_color_expected,
selection_color: selection_color_expected,
size: None,
};
let rendering_config_actual = RenderingConfig {
background_color: bg_color_actual,
padding_color: padding_color_actual,
inline_box_color: bg_color_actual,
cursor_color: cursor_color_actual,
selection_color: selection_color_actual,
Expand Down Expand Up @@ -351,11 +355,13 @@ impl CursorTest {
#[allow(dead_code)]
pub(crate) fn render_cursor(&self, cursor: Cursor) {
let bg_color_cursor = Color::from_rgba8(255, 255, 255, 255);
let padding_color_cursor = Color::from_rgba8(166, 200, 255, 255);
let cursor_color_cursor = Color::from_rgba8(0, 255, 0, 255);
let selection_color_cursor = Color::from_rgba8(0, 255, 0, 200);

let rendering_config_cursor = RenderingConfig {
background_color: bg_color_cursor,
padding_color: padding_color_cursor,
inline_box_color: bg_color_cursor,
cursor_color: cursor_color_cursor,
selection_color: selection_color_cursor,
Expand Down
1 change: 1 addition & 0 deletions parley/src/tests/utils/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ impl TestEnv {
text_color: Color::BLACK,
rendering_config: RenderingConfig {
background_color: Color::WHITE,
padding_color: Color::from_rgba8(166, 200, 255, 255),
cursor_color: Color::from_rgba8(255, 0, 0, 255),
selection_color: Color::from_rgba8(196, 196, 0, 255),
inline_box_color: Color::BLACK,
Expand Down
12 changes: 11 additions & 1 deletion parley/src/tests/utils/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl Default for ColorBrush {

pub(crate) struct RenderingConfig {
pub background_color: Color,
pub padding_color: Color,
pub inline_box_color: Color,
pub cursor_color: Color,
pub selection_color: Color,
Expand Down Expand Up @@ -73,10 +74,19 @@ pub(crate) fn render_layout(

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

img.fill(config.background_color);
img.fill(config.padding_color);

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

draw_rect(
&mut pen,
fpadding,
fpadding,
width as f32,
height as f32,
config.background_color,
);

for rect in selection_rects {
draw_rect(
&mut pen,
Expand Down
4 changes: 2 additions & 2 deletions parley/tests/snapshots/base_level_alignment_ltr-end.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/base_level_alignment_ltr-justified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/base_level_alignment_ltr-middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/base_level_alignment_ltr-start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/base_level_alignment_rtl-end.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/base_level_alignment_rtl-justified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/base_level_alignment_rtl-middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/base_level_alignment_rtl-start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/content_widths-max.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/content_widths-min.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/content_widths_rtl-max.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/content_widths_rtl-min.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/editor_select_all-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/editor_simple_move-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/editor_simple_move-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/editor_simple_move-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/editor_simple_move-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/editor_simple_move-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/full_width_inbox-exact.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/full_width_inbox-larger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/full_width_inbox-smaller.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/inbox_content_width-full_width.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/leading_whitespace-collapse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/leading_whitespace-preserve.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions parley/tests/snapshots/only_inboxes_wrap-0.png
4 changes: 2 additions & 2 deletions parley/tests/snapshots/overflow_alignment_rtl-0.png
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

4 changes: 2 additions & 2 deletions parley/tests/snapshots/placing_inboxes-end_nl.png
4 changes: 2 additions & 2 deletions parley/tests/snapshots/placing_inboxes-in_word.png
4 changes: 2 additions & 2 deletions parley/tests/snapshots/placing_inboxes-start.png
4 changes: 2 additions & 2 deletions parley/tests/snapshots/placing_inboxes-start_nl.png
4 changes: 2 additions & 2 deletions parley/tests/snapshots/plain_multiline_text-0.png
4 changes: 2 additions & 2 deletions parley/tests/snapshots/trailing_whitespace-0.png